Flush final log data to file before shutdown