This is not possible by default. You cannot control that kind of things from you application.
I see you an do something with javascript. See https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing
Don't know if this will work in Mendix….
Or you can use this:
https://appstore.home.mendix.com/link/app/78474/