Numerous sensors constantly monitor the health of a transformer. Like a human under close observation in the ER, a transformer's temperature, oil quality, oil level, voltage, current, dissolved gas, pressure and insulation are constantly being monitored in hopes to quickly identify problems and prevent a disaster.
When a transformer overheats, multiple stages of cooling are engaged to keep it within safe operating limits. It is up to a transformer protective relay to determine when to cool and how much. In rare circumstances a relay may decide to turn it off altogether.