Uninterruptible power supply - How it manages to provide electricity to electronic devices before it shutting down?
Its usually the inverse, most devices on the mains are built with enough input capacitance to handle at minimum a full mains cycle missing, so when the UPS detects the mains cycle not lining up with what it expects, it switches on its inverter stage

In the UPS it would normally keep its bulk DC rail charged up, this does consume some small amount of power, but it means the reaction time can be very short,

So the UPS has detected an issue, it disconnects the input mains from the output, and with a very short delay starts switching its inverter using that charged up bulk rail.

due to all this, the device is very unlikely to ever see more than 1 mains cycle without external power.