improve handling when read side of socket closes