Handle exception in closeConnection()