diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 0f9c332eda..839854e672 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -2461,13 +2461,17 @@ class Cache: self.shutting_down = True self.event_dispatcher.close() self._shutdown_fts() - from calibre.customize.ui import available_library_closed_plugins - for plugin in available_library_closed_plugins(): - try: - plugin.run(self) - except Exception: - import traceback - traceback.print_exc() + try: + from calibre.customize.ui import available_library_closed_plugins + except ImportError: + pass # happens during interpreter shutdown + else: + for plugin in available_library_closed_plugins(): + try: + plugin.run(self) + except Exception: + import traceback + traceback.print_exc() self._shutdown_fts(stage=2) with self.write_lock: self.backend.close()