close command window from windows forms

I have a simple Node.js program which execute through a button click from winform, that works fine, But i need to terminate the Node.js program and close the command prompt on another button click.How can i achieve this?

Cheers Jeev

If YOU start the process, you have an object of type process. This object supports kill which will end the process immediately.

UPDATED CODE

Public Class Form1

Dim MyProcess As Process

Private Sub btnStartPrcoess_Click(sender As Object, e As EventArgs) Handles btnStartPrcoess.Click

    If MyProcess Is Nothing Then
        MyProcess = Process.Start("cmd.exe", "arguments")
    End If

End Sub

Private Sub btnKillProcess_Click(sender As Object, e As EventArgs) Handles btnKillProcess.Click

    If MyProcess IsNot Nothing Then
        MyProcess.Kill()
        MyProcess.Close()
        MyProcess = Nothing
    End If

End Sub
End Class

If you need to end the process from a different method, you need to declare the process-variable on class level of course. And even Process.Start() has a return value of type process. So there is no need to SEARCH for the process - you already know it!

UPDATE

It's more or less nonsense, to do something like this:

MyProcess = Process.Start("cmd.exe", "/k notepad.exe")

Because it simply starts the cmd.exe which then starts notepad.exe. And of course the Process now "points" to cmd.exe and not to notepad.exe. If you want to have notepad running, it's obviously the best solution to start it DIRECTLY:

MyProcess = Process.Start("notepad.exe", "arguments for notepad, if needed")

You have used Process.Start("cmd.exe", "/k C:\Users\PROG21\Desktop\chat\exit.exe") to start the process. So declare a global Process varible and try;

Process exeProcess; 

on start button click:

 exeProcess = Process.Start("cmd.exe", "/k C:\Users\PROG21\Desktop\chat\exit.exe");  

On stop button click;

exeProcess.Kill();