Logging and exit cleanup.