I'm wondering how I can run a method when a window or tab closes. I've tried using the following...
window.onclose = () => {
// execute function
}
window.onbeforeunload = () => {
// execute function
}
but both of these only fire when I refresh the page not when I close it.
Any help would be very appreciated thanks!