correct closing of log files