ceaefdd fix possible shutdown assertion with -reindex-shutdown (Cory Fields)
Pull request description:
Fixes the assertion error reported here: https://github.com/bitcoin/bitcoin/pull/12349#issuecomment-365095741
Tree-SHA512: db8e2a275f92a99df7f17852d00eba6df996e412aa3ed3853a9ea0a8cb9800760677532efd52f92abbf2cdcc4210957a87a5f919ac998d46c205365a7a7dffca
Backport of Core PR 12349
https://github.com/bitcoin/bitcoin/pull/12349/files
Discovered while working on PR 12367 (D2906)
Depends on D2906