Cleanup on model termination. This function is called automatically from
model.terminate() and should not be called from user code.
WARNING: This is an internal function. Its use in user code is not recommended or supported, and its signature can change in future updates without warning. Use one of the suggested functions above instead, if applicable.