def terminate(self): try: gui.mainFrame.sysTrayIcon.preferencesMenu.RemoveItem(self.ocrSettingsItem) except wx.PyDeadObjectError: pass