Proper detection of browser close connection