I currently have a class that sets the current time when an object has been created from it. After the object has been created, I have code that goes into an infinite loop that sleeps once every second. All this is triggered by a user going to a web page (so at this point, your browser would just be waiting). Now, if the user stops their browser, the connection terminates. I'm trying to get the classes' \_\_destruct method to call when this happens so that I can track the time between loading of the script and termination by the user.

It doesn't seem to be working though. I'm assuming it's because the script isn't terminated properly, but if that's so, how can I call that code (or intercept the termination?)?

Thanks!