def terminate(self): super(AppModule, self).terminate() try: self.preferencesMenu.RemoveItem(self.settingsItem) except wx.PyDeadObjectError: pass