Browser tab close detection

Hi guys,
I’m using TimerTasks objects in my vaadin app and I want to cancel them after user close browser tab (just for clean up that stuff, kill threads etc. ) . I found several answers for my topic (like detach listeners , mixing up with hearhbeat interval ) but it’s not what I’m looking for . I’m looking forward for any help with that , cheers

Why isn’t detach good enough, i.e. either override detach() in your UI or using a DetachListener?