How can I stop a process cleanly given it's name?

I can use TerminateProcess but it says it does not allow the application to clean up and of course I want it to clean up. This application does not have a WM_CLOSE or WM_QUIT.. I tried.. and I cannot send it PostMessage(HWND, WM_QUIT, 0, 0);

Why? because instead of it closing, it will minimize to system tray -__-

Again I don't want to use a dirty thing like TerminateProcess so does anyone have any ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.