Problem: When FlushChainstateBlockFile() fails, shutdown is requested, but FlushStateToDisk() still writes block-index metadata and coins data, then advances m_last_flushed_block.
Those writes can record a block even though its block or undo data may not be durable.
Fix: Return the flush error before those writes, leaving m_last_flushed_block at the last successfully flushed block.
History:
- #27866 proposed returning here to avoid writing metadata for block data that failed to flush, but review requested a test and caller audit before changing behavior, so it was deferred as the current TODO; this PR now resolves it.
- #34897 later introduced
m_last_flushed_blockto prevent persistent indexes from advancing past flushed chainstate; this fix keeps it at the last successful flush.</details>