You could probably write a small program that will call a batch file to kill the process
TASKKILL /F /IM "notepad.exe"
or write a small program that uses the functions below to check if the process is running and then kill the process with the second function below. There is more to it than just that though since you need winapi references. Are you familiar with VB? I could send you the module you would need to make it happen.
Public Function Is_Process_Running(ProcessName As String) As Boolean
Dim Snapshot As Long
Dim Process As PROCESSENTRY32
Dim Success As Long
Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If Snapshot = -1 Then Exit Function
Process.dwSize = Len(Process)
Success = ProcessFirst(Snapshot, Process)
If Success = 1 Then
   Do
      If InStr(1, Process.szexeFile, ProcessName) > 0 Then
         Is_Process_Running = True
         Call CloseHandle(Snapshot)
         Exit Function
      End If
   Loop While ProcessNext(Snapshot, Process)
End If
Call CloseHandle(Snapshot)
End Function
Public Sub Kill_Process(ProcessName As String)
Dim uProcess As PROCESSENTRY32
Dim RProcessFound As Long
Dim Snapshot As Long
Dim SzExename As String
Dim ExitCode As Long
Dim MyProcess As Long
Dim AppKill As Boolean
Dim AppCount As Integer
Dim i As Integer
Dim WinDirEnv As String
Dim Response As Integer
        
If ProcessName <> "" Then
   AppCount = 0
   uProcess.dwSize = Len(uProcess)
   Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
   RProcessFound = ProcessFirst(Snapshot, uProcess)
   Do
      i = InStr(1, uProcess.szexeFile, Chr(0))
      SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
      WinDirEnv = Environ("Windir") + "\"
      WinDirEnv = LCase$(WinDirEnv)
      
      If Right$(SzExename, Len(ProcessName)) = LCase$(ProcessName) Then
         Response = MsgBox("There is a cmd.exe session already running." & vbCrLf & "It may be an orphaned session." & vbCrLf & vbCrLf & _
            "Do you want to terminate the session?", vbYesNo, "Potential Orphaned Session")
      
         If Response = vbYes Then
            AppCount = AppCount + 1
            MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
            AppKill = TerminateProcess(MyProcess, ExitCode)
            Call CloseHandle(MyProcess)
         End If
      End If
      
      RProcessFound = ProcessNext(Snapshot, uProcess)
   Loop While RProcessFound
   
   Call CloseHandle(Snapshot)
End If
End Sub