closing the connection when the request is complete