mockserver: Provide an Event that can be used to shutdown the server instead of calling terminate(), which doesn't clean up the socket correctly.