server.close() before sys.exit() to avoid hang