Claim the lock when shutting down.
Claim the lock when shutting down.

This is in place to cover a pretty narrow scenario where someone calls
Vacuum on one thread and then immediately calls shutdown on another.
Like if you have a periodically scheduled vacuum operation. If we don't
do this then vacuum could slip past the shouldQuit CTS and run BEGIN
TRANSACTION by the time we flush, causing a 'cannot start a transaction
within a transaction' error.

ghuntley/AkavacheSandpit,PureWeen/Akavache,akavache/Akavache,bbqchickenrobot/Akavache,mms-/Akavache