close the log file if you need to.
centralized failure system; also prints the last logged lines for debugging.