Here are some examples of HTML events: An HTML web page has finished loading; An HTML input field was changed; An HTML button was clicked; Often, when events happen, you may want to do something. When the browser is closed, you aren't really going to be able to capture any server-side code (since actually closing the browser is a client-side operation) however there is a Javascript event that is called prior to a window closing called onbeforeunload which can fire a Javascript function when the browser is about to be closed : The close event is fired on an HTMLDialogElement object when the dialog it represents has been closed. If the browser is closed then there was no javascript-update possible so the session had a max-timeout of 5 minutes. Usually the browser detects when you close it, it sends you a message (message “do you want to close this window?”). This happens if user close the browser or move to different page. onunload occurs when the user navigates away from the page (by clicking on a link, submitting a form, closing the browser window, etc.). Note: To handle the closing of a window, use onbeforeunload or onunload . If you do not need to do something on the server when the client closes the browser, then there really is no real reason to be notified. The onclose property of the GlobalEventHandlers mixin is an EventHandler for processing close events sent to a