Here's a suggestion:
Mark the time when starting the thread.
Then during the script run, add a time check action and compare the time difference with your desired value.
-> Take appropriate action.
Since you're having alot of problems, send me a PM with your current theory on why its crashing so I can help you dive into this issue and get it fixed for you if possible!