code: def on_quit(self, event):
          
          if self.parent.grid_frame:
              if self.parent.grid_frame.grid.changes:
                  dlg = wx.MessageDialog(self,caption="Message:", message="Are you sure you want to exit the program?\nYou have a grid open with unsaved changes.\n ", style=wx.OK|wx.CANCEL)
                  result = dlg.ShowModal()
                  if result == wx.ID_OK:
                      dlg.Destroy()
                  else:
                      dlg.Destroy()
                      return
          if self.parent.grid_frame:
              self.parent.grid_frame.Destroy()
          # if there have been edits, save all data to files
          # before quitting
          if self.parent.edited:
              self.parent.er_magic.write_files()
          self.parent.Close()
          try:
              sys.exit()
          except TypeError:
              pass
docs: shut down application