Or, if your computer is ATX, then you should be able to do something where the accessory power trips an instantaneous switch/relay that does what a press of the power button would do. Then your OS can shut itself down based on that signal, just as if the front power button were pressed.
_________________________
Bitt Faulk