What's a UPS?
An Uninterruptable Power Supply.
Basically a bank of rechargable batteries plus electronic switching (usually includes surge suppression and often mains filtering as well) that sits between the mains supply and PC/monitor.
The idea is that if the mains fails the batteries can supply enough power to give you time - so long as you act quickly enough - to save what you're doing and shut the computer down properly. Most come with software that monitors the mains and can be set to trigger an automatic PC shutdown/switch to hibernation (RAM copied ot hard drive then shut-down) if the mains fails as well (but an automated shutdown won't save your work.
I've had one (an old Belkin model) for years - we get zero-warning power cuts two or three times a year, and "glitches" like someone's thrown a big switch back at the distribution transformer station quite often. And this is in an industrial inner-city in the UK...
A few years ago the mains went on/off about 5 times in under a second, which killed the PC motherboard and psu.
Hence the investment in a UPS.
You do need a pretty hefty one though - modern PCs drain the batteries very quickly.