Sage 300 UI Customization Issue in Closing external application.

I have created external .net application to download data in excel format from Sage 300 2020  and i included that .exe inside sage.If i close the sage window, external application UI is still open..I want to close the external application if sage is closed.Kindly please let me know how to handle this Issue?