If you have a special cable (USB A - Ethernet) then you can connect an
uninterruptable power supply from APC with your computer.
This program will detect when your computer runs on the battery of the
UPS.
Then it can save all open documents and/or shut the computer down.
It's a hybrid CD.
The software for Windows is called PowerChute.