create yourself a Global variable to hold the time. Don't sleep, as you need to return control back to linuxmce.
Then , in Process IDLE, you can compare that global time variable with the current time...
and stop it when it gets close to 60 seconds..
The Process IDLE command is fired at your code about every 3-4 seconds. I use that to check for timeouts.
HTH, and good luck!