def register_closing_warning_callback(self, callback: Callable[[], Optional[str]]) -> None:
        """
        Registers a callback that will be called when the wallet is closed. If the callback
        returns a string it will be shown to the user as a warning to prevent them closing the wallet.
        """
        assert not asyncio.iscoroutinefunction(callback)
        def warning_callback() -> Optional[str]:
            try:
                return callback()
            except Exception:
                self.logger.exception("Error in closing warning callback")
                return None
        self.logger.debug(f"registering wallet closing warning callback")
        self.closing_warning_callbacks.append(warning_callback)

        Registers a callback that will be called when the wallet is closed. If the callback
        returns a string it will be shown to the user as a warning to prevent them closing the wallet.
        
electrum/gui/qt/main_window.py