The order should be:
- stop scheduler
- delete wallet
- delete scheduler
This is a partial backport of core#23403
https://github.com/bitcoin/bitcoin/pull/23403/commits/68018e4c3e76f7e5bebf5f90ffd972c7bf01e0a0
The other commit in that pull request is not applicable to Bitcoin ABC, for now. It has a dependency on core#23288, which has itself a lot of dependencies on recent descriptor wallets developments.