You should use an UPS software which usually comes with it to control your shutdown.
I'm using Powerware 5115 on my PC and I have installed Lan Safe software that comes with it.
Now I have full control over it, it also shuts down my PC if power isn't restored in 5 minutes.
See if you can find something for your UPS model here:
http://www.apc.com/tools/download/index.cfm?isocountrycode=ww&tsk=