Hot reloading removes extension window

Isaac Sim Version

4.5.0
4.2.0
4.1.0
4.0.0
4.5.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):

Topic Description

This issue has already been described here for an older version of IsaacSim.

However, IssacSim 4.5 BaseSampleUITemplate doesn’t take a parameter keep_window_open, so the solution provided back then is not applicable.

Q: How can I prevent my extension closing every time the code is reloaded?

Details

I assume the the problem lies in the following method provided by the extension UI template VS code generates automatically:

    def cleanup(self):
        """Clean up window and menu"""
        if self._window is not None:
            self._window.destroy()
            self._window = None
        # destroy menu
        if self._menu is not None:
            try:
                omni.kit.ui.get_editor_menu().remove_item(self._menu)
            except:
                omni.kit.ui.get_editor_menu().remove_item(self._menu_path)
            self._menu = None

However, if I remove / change this cleanup method, the window stays open, but hot reloading doesn’t work anymore.