<!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->
<!-- Describe the issue -->
I am loading descriptors into bitcoind using the rpcclient with the function: importdescriptors, it automatically starts rescanning the blockchain. Now when I try to unload the wallet, bitcoin-cli will allow me to do it (wallet disappears from the listwallet section, but it will not abort the rescan. Thats a problem bc now when trying to reload the wallet, the wallet sqlite db is locked by bitcoind and this wallet is unusable unitl the rescan is over. abortrescan will not work bc the wallet is not loaded anymore according to bitcoin-cli listwallets. The only solution for me was to delete the wallet dir and create a new wallet with the same name. Now everything works as expected, but as soon as I want to unload the wallet again, bitcoind crashes
<!--- What behavior did you expect? -->
The unloadwallet function should internally abort the rescan and unload the wallet, so that it can be reloaded afterwards without waiting for the rescan. Or it should fail and leading the user to abort the rescan with abortrescan
<!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->
- Create a descriptor wallet
- Import a descriptor and unload the walllet while bitcoind is still rescanning
- Now you are stuck bc abortrescan will not work bc wallet is not loaded and the only solution is to delete the wallet dir
- Now Create a new wallet with the same name and import the descriptors again. When the wallet is faster synced then the old process still syncing, and you unload the wallet, bitcoind crashes
<!--- How reliably can you reproduce the issue, what are the steps to do so? -->
Linux 5.10.103-v8+ [#1529](/bitcoin-bitcoin/1529/) SMP PREEMPT Tue Mar 8 12:26:46 GMT 2022 aarch64 GNU/Linux
<!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->
bitcoind v.23.0 (release binary for raspberry pi)
<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->
<!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->
<!-- Any extra information that might be useful in the debugging process. -->
<!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->