diff --git a/gajim/plugins/pluginmanager.py b/gajim/plugins/pluginmanager.py
index 4c9a15e02193570c694be07f543a5f9c55eb3e1e..258d04f59e2a6af4664056a669ae51e96de5df97 100644
--- a/gajim/plugins/pluginmanager.py
+++ b/gajim/plugins/pluginmanager.py
@@ -543,10 +543,12 @@ def deactivate_plugin(self, plugin: GajimPlugin) -> None:
 
         self._remove_events_handler_from_ged(plugin)
         self._remove_name_from_encryption_plugins(plugin)
-        self._unregister_modules_with_handlers(plugin)
 
-        # removing plug-in from active plug-ins list
+        # deactivate() must be before _unregister_modules_with_handlers(),
+        # because plugin.deactivate() may want to use the module
         plugin.deactivate()
+
+        self._unregister_modules_with_handlers(plugin)
         self.active_plugins.remove(plugin)
         app.settings.set_plugin_setting(plugin.manifest.short_name,
                                         'active',