Honestly, that’s a tough situation unless you plan ahead for it.
The good news is that if you can plan ahead, there are several reasonable approaches to getting that machine shut down cleanly.
Become a Patron of Ask Leo! and go ad-free!
Put the monitor on the UPS
I assume there’s some reason you can’t, but the simplest solution is to make sure the monitor is also plugged into the UPS. Then, when the power goes down, you’ll have both computer and screen running, and can see enough to shut down the computer properly.
The downside is that screens take power — sometimes a fair amount. When your computer is running on the back-up power supplied by the UPS, it won’t run as long, since the computer plus the monitor will drain the UPS’s battery faster than the computer alone.
I have at least one machine in my basement configured exactly this way: I want to maximize its run time on battery backup, so I purposely don’t plug the monitor into the same UPS.
My approach to that machine is to connect to it using remote access from one of my other machines.
I have my local network configured to stay running during a power outage by having my routers and access points on the UPS instead of, say, that extra monitor. Then I can easily connect to the machine remotely using a laptop — which, when you think about it, has a built in UPS by virtue of its battery.
The remote access technology varies. I use Microsoft’s Remote Desktop client, or Team Viewer, or some other kind of remote access tool. I’ve even done remote shutdowns via the Windows Command Prompt.
Mobile remote access
This is one I’ve done while away from home. I happen to use TeamViewer, but there are other alternatives as well. Using my smartphone, I can connect to my home PCs and do just about anything … including turning them off.
It’s not a solution for really using the computer for anything significant via your mobile phone’s small screen (though I admit I’ve done that, too, in a pinch), but it’s perfect for just hitting the Start menu and the Shutdown option.
This option, in particular, requires that your network equipment as well as the modem be on your UPS, so in the event of a power outage, your network keeps operating. (It also requires that whatever caused your power to fail did not also impact your internet connection.)
Let the UPS do it
Many, if not most, uninterruptible power supplies have the ability to connect to your computer via USB specifically for this scenario.
When the power fails, the UPS notifies the computer. Software on the computer — sometimes built into the OS, sometimes software that comes with the UPS — then decides what to do and when. Typically, you can configure a delay, so after some time running on battery, the software can shut down the computer cleanly on your behalf.
When all else fails
Unfortunately, if you’ve not prepared ahead, all you can really do is long-press the power button.
It’s definitely not ideal, but it’s marginally better than an unscheduled shutdown when the UPS runs out of power.
If you found this article helpful, I'm sure you'll also love Confident Computing! My weekly email newsletter is full of articles that help you solve problems, stay safe, and give you more confidence with technology. Subscribe now and I'll see you there soon,