prevent data loss while promoting from second replica to owner.

Fixes #2785
This was copied from the test code I provided in #2785. I was indeed using the `stop` latch as an atomic flag. This could easily be replaced by an `AtomicBoolean`