Wallet registration locks in main.cpp + UnregisterAllWallet() function

Right now in the current master these hooks aren't really being used - a single wallet is registered at startup in init.cpp and is unregistered at shutdown, also in init.cpp. But in order to support dynamic loading and unloading of transaction listeners, it is necessary to lock these functions. It is also convenient to have an UnregisterAllWallets() function and to call that upon shutdown instead of just calling it on the single main wallet that master currently has.