Close connection when an exception occurs.