Flush IMAP data to disk when stopping. Closes #5095.
Merge remote-tracking branch 'drebs/feature/in-memory-store-with-data-flushing' into develop