There isn't a reliable way to know if a browser has closed.
Browsers crash, operating systems crash, network connections crash.
There are many situations where a browser will not be able to communicate a problem to the server.
Your server application should not rely on being able to tell if the user is still looking at your application.