Technically, some internal datastructures may be in an inconsistent
state if we do this, though there are no known bugs there. Still,
for future safety, its much better to only unlock cs_main if we've
made progress (not just tried a reorg which may make progress).
This is extracted from Core PR13023 : https://github.com/bitcoin/bitcoin/pull/13023/commits/ecc3c4a019e6db30e208b8554b1a3658dcb9a80a