def on_quit(self, event, wind=None):
        """
        shut down application if in the main frame.
        otherwise, destroy the top window (wind) and restore
        the main frame.
        """
        if wind:
            wind.Destroy()
        if not self.parent.IsShown():
            self.on_show_mainframe(None)
            # re-do the quit binding
            self.parent.Bind(wx.EVT_MENU, self.on_quit, self.file_quit)
        else:
            self.parent.Close()