Replaces #17852.
Currently, the latest index state may not be committed to disk on shutdown. The state is committed on ChainStateFlushed callbacks and the current init order unregisters the indexes as validation interfaces before the final ChainStateFlushed callback is called on them.
Issue identified by paulyc.
For review: an alternative or supplemental solution would be to call Commit at the end of BaseIndex::Stop. I don't see any harm in doing so and it makes the less prone to user error. However, the destructor would have to be modified to not call Stop because Commit calls a virtual method, so I figured it wasn't worth it. But I'm curious how others feel.