Summary
Please expose either an Event hook or a similar API, that can be synchronously invoked when users close the browser tab or window.
Why
These events can be used to prompt the user to save any pending changes before closing the tab and losing the state for good.
How
Maybe the beforeunload window event listener is enough, but care must be taken to make sure the event is propagated to the browser only if confirmed by user interaction.
Alternatively, if this is not feasible, just add a toggle to enable the native browser unsaved changes reminders.