g_compressAndDumpStateSyncEvent was Set() before destruction of file object (i.e. before flushing changes and closing file). Also, adds Common::ScopeGuard wrapper for RAII.