Flush logfile when going to sleep