To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.
I need to know when a page is closed -- I have to clean some data structures attached to the corresponding UI and View objects (such as event bus subscriptions)
In Vaadin 6, I could register a CloseListener to the page (not only to pop-up browser Windows as is now the case).
The reason why it has been removed after version 6, is that it was not working reliably for all the browsers, and there was no alternative back then, since this information is not just available from the browser.
The onunload event is triggered when the browser window closes, but it is also triggered for refresh, navigating away from page...
You can setup the heartbeat interval to be lover to get the UI.detach triggered faster, as the UI is closed after three missed heartbeats (if I remember correctly).