I'm using onCloseRequested to confirm shutdown of an app while it's doing certain critical work.
the code looks like:
const unlisten = await appWindow.onCloseRequested(async (ev) => {
const confirmed = await confirm('[confirmation message]');
if (!confirmed) {
// user did not confirm closing the window; let's prevent it
ev.preventDefault();
}
});
// do work
unlisten()
However, after the work is done and unlisten() called, the window cannot be closed normally.
It doesn't ask for confirmation, it simply does nothing.