handles closed connection