I used the QGIS Plugin Builder to create a plugin where the *main.py* file imports dockwidgets and class from its own file and from other files. A button on the toolbar executes the `run(self)` function in *main.py* where it loads the imported dockwidgets, classes, connecting buttons to functions etc. Another button on the toolbar closes the plugin by executing the `onClosePlugin(self)` function. This function only closes dockwidgets loaded from *main.py* (so not from other files) and disconnects its buttons. The imported classes are untouched. **Should everything that has been imported and loaded from the plugin be removed and unloaded? And if so, what is the best method?** When I import dockwidgets and classes from other files, I use the following in my *main.py* from some_Dockwidget import someDockwidget from general_Class import generalClass Which are then called in `run(self)`: self.someDockwidget = someDockwidget() self.generalClass = generalClass() --- I found [this post](https://gis.stackexchange.com/questions/353598/qgis-plugin-closing-all-open-pyqt-dialogs) which closes all QDialog boxes. I have used the following to close all dockwidgets but can it be adapted to close/unload/delete everything that has been imported/loaded? items = vars(self) for i in items: item = items[i] if isinstance(item, QDockWidget): item.close()