Close connection when there's an error.