There is a widget for that: https://appstore.home.mendix.com/link/app/78474/Bizzomate/Bizzomate-LeaveAction
We are using this leave action widget. There are certain actions from certain browsers not completely detected by this widget. So, its better to check if it suffice your needs.
For us, we have some issues reported with Edge, if I remember it right.