gui: Defer removeAndDeleteWallet when no modal widget is active
Summary: Backport of core PR15614.
Test Plan:
ninja check check-functional ./src/qt/bitcoin-qt -regtest -server -wallet=w1 & ./src/bitcoin-cli -regtest generate 1 # Get out of IBD if needed
Open the "Parameters=>Encrypt wallet" window and leave it open.
./src/bitcoin-cli -regtest unloadwallet=w1
Before this patch, the GUI crashes. After this patch, the GUI does
nothing, and closing the "Encrypt wallet" window does trigger the wallet
unloading.
Reviewers: #bitcoin_abc, nakihito
Reviewed By: nakihito
Differential Revision: https://reviews.bitcoinabc.org/D5086