Fix deadlock in shutdown

If AAE requests and an election is occuring at the time of a shutdown, it can
cause a deadlock in the tests.