This depends on how you launched the program. Did you start it from MQL5 code as well?
If not, then you need to search the right program using GetClassName and then use PostMessage to send WM_CLOSE to it. At least that's how it worked with MT4 long time ago.