Close the connection on IOExceptions instead of crashing