hmm, it's not possible with php to run a file when a user closes the browser, at least not that i know of.
the only way i could think of it would be a js which will call the logout when the browserwindow gets closed, but i'm not sure (i don't know JS very well

)
also it's not a good idea, as if someone has more than one window open, and just closes one, he'd get logged out