code: def on_close(self, evt):
      
      self.stop() # DoseWatcher
      if evt.EventObject is not self: # Avoid deadlocks
        self.Close() # wx.Frame
      evt.Skip()
docs: Pop-up menu and wx.EVT_CLOSE closing event