When a user launches the AP activity in a tab or window, there is a chance that they may close it accidentally. I want to make an API call in JS to a server to close some resources if this happens. I found window.onbeforeunload online. I want to know if there is something similar. I tried on unload, but it does not call the script. I think that triggers only when transitioning from one slide to another.