If you mean server-side, the best way is to run a beat. If none of the windows of this web application is open, nothing sends a heartbeat, and after a while the server finds out that the application is disconnected.
, 100%, (kill/crash/reboot), - cookie,