Fix the way that we handle closing the connection to comply with the HTTP protocol.