Fix ENABLE_SAFE debugging option.
This seems to fix the problem end-of-program crash.