Python - After 1 second i cant exit the GUI, when ever the gtk.main() is called it never exit, how can i exit?

view story

http://stackoverflow.com – How can i exit the GUI after running gtk.main() ? its not exiting after 1 second Only way it exit is to use this: $ echo "disconnect" | nc localhost 58887 import re,os, time, socket, datetime, threading, subprocess import gobject, gtk gobject.threads_init() class gui(object): def listener(self, sock, *args): conn, addr = sock.accept() gobject.io_add_watch(conn, gobject.IO_IN, self.handler) return True def handler(self, conn, *args): line = conn.recv(4096) if not len(line): return False else: if line: if line.startswith("disconnect"): (HowTos)