close logfile when not in use