You can kill a process using the
Process.Kill
method.
http://msdn.microsoft.com/en-us/library/t71a733d(v=vs.80).aspx[
^]
The following is a more detailed example but in essence the code is:
using System.Diagnostics;
Process[] processes = Process.GetProcessesByName(processName, machineName);
foreach(Process process in processes)
{
process.Kill();
process.WaitForExit();
}
http://weblogs.asp.net/stanleygu/archive/2010/03/31/tip-13-kill-a-process-from-local-to-remote.aspx[
^]
Although killing processes is not a good practice. Especially if it's your process. You could decide on some type of exit pointer. Perhaps specific content in an SQL table row or a text file. If you want the running process to stop, set the pointer, the running process, when it detects the pointer, exits nicely from what ever it is doing.