fix possible shutdown assertion with -reindex-shutdown
fix possible shutdown assertion with -reindex-shutdown

Credit @eklitzke for reproducing.

Github-Pull: #12349
Rebased-From: ceaefdd5f362537a1908d0095059e4be788f3dee
Tree-SHA512: bdc614d3c3fba23147be9528c581e25bbf1f0c359b525b4a05472ab42484724a8b34c8b3ed151f3ff23e48235e972950f9daa155d9ca3c4a9de6d61bf0591b4b

qtumproject/qtum,MazaCoin/maza,DigitalPandacoin/pandacoin,ppcoin/ppcoin,digibyte/digibyte,myriadcoin/myriadcoin,starwels/starwels,MazaCoin/maza,gjhiggins/vcoincore,MazaCoin/maza,starwels/starwels,viacoin/viacoin,myriadteam/myriadcoin,GroestlCoin/bitcoin,peercoin/peercoin,1185/starwels,deeponion/deeponion,deeponion/deeponion,ahmedbodi/vertcoin,viacoin/viacoin,qtumproject/qtum,ahmedbodi/vertcoin,peercoin/peercoin,MazaCoin/maza,viacoin/viacoin,digibyte/digibyte,ahmedbodi/vertcoin,digibyte/digibyte,1185/starwels,particl/particl-core,tecnovert/particl-core,qtumproject/qtum,deeponion/deeponion,vertcoin/vertcoin,myriadcoin/myriadcoin,myriadteam/myriadcoin,ahmedbodi/vertcoin,GroestlCoin/GroestlCoin,DigitalPandacoin/pandacoin,tecnovert/particl-core,digibyte/digibyte,GroestlCoin/GroestlCoin,MazaCoin/maza,particl/particl-core,peercoin/peercoin,myriadteam/myriadcoin,deeponion/deeponion,GroestlCoin/bitcoin,viacoin/viacoin,tecnovert/particl-core,qtumproject/qtum,digibyte/digibyte,DigitalPandacoin/pandacoin,tecnovert/particl-core,myriadcoin/myriadcoin,qtumproject/qtum,particl/particl-core,GroestlCoin/GroestlCoin,GroestlCoin/bitcoin,particl/particl-core,ppcoin/ppcoin,peercoin/peercoin,GroestlCoin/bitcoin,1185/starwels,GroestlCoin/GroestlCoin,tecnovert/particl-core,digibyte/digibyte,1185/starwels,gjhiggins/vcoincore,DigitalPandacoin/pandacoin,particl/particl-core,GroestlCoin/GroestlCoin,gjhiggins/vcoincore,qtumproject/qtum,viacoin/viacoin,ppcoin/ppcoin,starwels/starwels,myriadteam/myriadcoin,gjhiggins/vcoincore,viacoin/viacoin,ahmedbodi/vertcoin,starwels/starwels,vertcoin/vertcoin,vertcoin/vertcoin,1185/starwels,ppcoin/ppcoin,1185/starwels,GroestlCoin/bitcoin,DigitalPandacoin/pandacoin,ahmedbodi/vertcoin,myriadcoin/myriadcoin,peercoin/peercoin,myriadcoin/myriadcoin,tecnovert/particl-core,starwels/starwels,vertcoin/vertcoin,vertcoin/vertcoin,myriadteam/myriadcoin,deeponion/deeponion,deeponion/deeponion,gjhiggins/vcoincore,DigitalPandacoin/pandacoin,gjhiggins/vcoincore,peercoin/peercoin,myriadcoin/myriadcoin,GroestlCoin/bitcoin,MazaCoin/maza,GroestlCoin/GroestlCoin,particl/particl-core,vertcoin/vertcoin,myriadteam/myriadcoin,starwels/starwels,qtumproject/qtum