Windows

Go to START and then RUN, type in gpedit.msc and press enter to bring up group policy editor.  
Expand Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown)

Double click the Shutdown icon, fill in the path to the stop.bat command shipped with the product.

Example: C:\Program Files (x86)\Skybot\Skybot Scheduler Agent\stop.bat

Now any time your computer shuts down, the AGENT will go to inactive instead of failed.

Linux,

Just add the path to stop.sh to whatever shutdown scripts you are running (rc0.d and rc6.d)