Close log file after writing.