Added locks on the setpwalletRegistered functions in main.cpp and added an UnregisterAllWallets function.