While checking #16661 I stumbled upon what seems to be a lifetime issue in ReleaseWallet(CWallet* wallet) (wallet.cpp).
After delete wallet; the pointer is invalid and shouldn't be used like in the call g_unloading_wallet_set.erase(wallet).
The code was introduced in #14941 which was merged into master on January 15, 2019.
In addition to fixing this specific instance it might be worth thinking about how we can use static analysis to automatically catch this class of issues going forward :-)