I need a way (some event(s)) to detect when user leaves current page. By "leaves" I mean he switched to another application/tab. I have tried visibilitychange
visibilitychange