Fix race condition while shutting down a ring.