Try any one, 1 - Handle session_end and rest the DB flag. session_end fires even user closes the browser(not immediately). 1 - Handle the window closing event using JS, do AJAX call to reset the DB flag. 2 - Run a DB job which will check the records frequently and resets the flag. :)
Navaneeth How to use google | Ask smart questions