def stop_server (port):
    """send QUIT request to http server running on localhost:<port>"""
    conn = httplib.HTTPConnection("localhost:%d" % port)
    conn.request("QUIT", "/")
    conn.getresponse()
send QUIT request to http server running on localhost:<port>
recipes/Python/336012_Stoppable_HTTP_server/recipe-336012.py