Flush log entries before shutdown