The usual Python HTTP server never stops. Since there is the timout option in the socket module, there is an easy way to do a clean shutdown of a running server.
Override the server_bind method to set a timeout on the main socket. Then override the get_request and serve methods to break if the attribute run is set to False.
This Method can be used for all types of servers based on the SocketServer module.