try to improve closed connection error handling