You can try a timeout through eval.
In reply to Re: CountDownTimer for my perl program, by tmharish in thread CountDownTimer for my perl program, by venky4289