The EA_Disconnect event enables the Add-In to respond to user requests to disconnect the model branch from an external project.
This function is called when the Enterprise Architect closes. If you have stored references to Enterprise Architect objects (not particularly recommended anyway), you must release them here.
In addition, .NET users must call memory management functions as shown below:
Also look at EA_Connect.