Fix a race condition in the master election.

It was only when stopping the election, so not too major, but still, let's fix it!