How to stop the Physics engine Via script ???

In my project I am starting the Physics Engine via script. But when it comes to stopping it via script it gets a little messy, since the main thread is taken by the physics engine and the control flow stops until the user hits ESC button.

I did try to add a Draw.ESCKEY with a period of time, but this is not working also, for some odd reason the QAdd(id, Draw.ESCKEY, 1 , 2) is not adding the event to the queue after 2 seconds.

Am I doing something wrong with the QAdd, because I followed the API but its not working?
Thanks