Actually, the only locking really needed is when unloading wallets. The rest of the wallet locking could be handled by the wallet class itself. So it seems an even better solution is to just lock inside the UnregisterWallet method for each wallet.