Close (or Pause) Threads on closing window

Hello everybody!

I have an App that is using Vaadin Flow 10 and Spring boot (2.0.5). There I have some threads running and when the app is inactive over 30 min it will trigger the detach method. This is ok since the user can open multiple tabs and use the same thread for all the tabs or come back to the app before the 30 minutes. But what if I want to close (or pause) the threads AS SOON AS the user close ALL the tabs / windows.

I have been looking around and everybody talks about the @onDetach event but this event is ONLY triggered (at least for me) after the time session out (30 minutes). I also implemented the SessionDestroyListener but it actually didn’t work out.

Can you give some leads please :slight_smile:

Thanks!