[Chronik] Fix: "Segmentation fault" during shutdown
Summary: The position of chronik::Stop() makes it so the indexer might still process freed memory. Moving it after GetMainSignals().FlushBackgroundCallbacks() fixes this.
Test Plan:
The functional test should fail if the chronik::Stop() is not moved as in this diff, and should pass if chronik::Stop() is moved as in this diff.
Alternatively, this should also reproduce the bug:
- ninja
- IBD for a few minutes
- Stop the node: Segmentation fault
Reviewers: Fabien, PiRK, #bitcoin_abc
Reviewed By: Fabien, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D13863