How to terminate another appliation using c++/c#/vc++ gracefully? : I have an application running an infinite loop and performing some important functions in that loop. I need to provide the user with another application which would terminate the application with infinite loop. The problem is what if the user terminates the application when it is inside loop performing some operation. It would lead to inconsistent state. I tried kill() and TerminateProcess but they didn't help. Is there any way i could signal the application with infinite loop that complete your iteration and exit? I am open to solutuons in c#,cpp and vc++.