Making sure Thread.end(:with_connection) is called before we checkin the connection, to avoid entering into a bad state with checkin connection.