added a way to terminate the server