I've recently added a watchdog procedure to the Standard Libraries Project that exits safely after a specified period of inactivity.
Works on version 9 and upwards, GUI or Char, UNIX/Linux and Windows.
http://www.oehive.org/project/lib
If anyone needs something like this you may want to have a look at slib/watchdog.p.
To start the procedure -
run slib/watchdog.p persistent.