def cleanup()

in operators.py [0:0]


    def cleanup(self, context):
        prefs = context.preferences.addons[__package__].preferences
        prefs.downloading = False

        if self._progress_queue:
            try:
                while not self._progress_queue.empty():
                    self._progress_queue.get_nowait()
            except Exception:
                pass
            self._progress_queue = None

        if self._timer:
            try:
                bpy.context.window_manager.event_timer_remove(self._timer)
            except Exception:
                pass
            self._timer = None

        self._download_thread = None

        for window in context.window_manager.windows:
            for area in window.screen.areas:
                if area.type == "PREFERENCES" or area.type == "VIEW_3D":
                    area.tag_redraw()