Additional logging.

Added logging when program exits.

Moved excepthook out of closing() context.