Cleanup, including error stack logging.