Is there a trick to automatically close Dialogs when a user navigates Back in the browser?

I would like to automatically close a fullscreen dialog (or ask to close if content has changed and needs to be saved), when a user navigates back in the browser. Does anyone know a good way of solving this?

Hi! Have you tried the Event Handler “On View Unload” on the view behind the dialog? It could run an action closing the dialog.

Seemed to be working when I tested it!

That works, but the browser still navigates back in history. It would be nice if there was built in way to detect that the user clicks back before the URL changes.