Patch infinite read when socket is closed.