MLDeinitialize() voidMLDeinitialize(MLENVenv) deinitializes functions in the MathLink library. An appropriate call to MLDeinitialize() is generated automatically when an external program is created from MathLink templates. Any external program that uses the MathLink library must call MLDeinitialize() before exiting. MLClose() must be called for all open links before calling MLDeinitialize(). See the Mathematica book: Section 2.12.14.