More exception cleanups

There were some cases in which a destructor might have thrown an
exception, which is poor behaviour.  We're now catching any possible
exceptions in destructors, and just eating them.

Also closed out the log object in cleanup_log.  It may create some
unhandled exceptions if somebody tries to write to the log after it's
been closed, but that should only be done on program termination, and
nothing after the cleanup_log call tries to write to the log.