self.connect(self, SIGNAL('lastWindowClosed()'), self.byebye)
self.main.show()

def byebye(self):
    self.exit(0)

def main(args):
    global app
app = App(args)
app.exec_()
if __name__ == '__main__':
    main(sys.argv)
Python: всплывающее окно PyQt