Ensure log file is closed