Terminate Custom thread when browser tab is close.

Hi,

I have an extra thread that, executes a method every 20 seconds. How can I terminate this thread when a user closes the browser. I user with onDetach() method but it’s not working for me. Can anyone help me for it?
unknown.png

This cookbook recipe might be helpful Vaadin Cookbook - code snippets for common tasks