Handle the case that the endpoint closes the connection