Mutex fixes for writing an exported wallet.