You can do:
Process p2 = runtime.exec("c:\\windows\\system32\\taskkill /IM program.exe")
it is a standard kill not a forceful one (that requires /F), hence it will simply notify the program it should terminate spontaneously.
I could not try with your program, but I opened notepad typed some text and before saving, I used this way to terminate it and notepad asked me if I wanted to save my work.
With the /F option notepad was terminated immediately leaving the file unsaved.
This is the same difference you have in unix between kill
vs and kill -9
.
Note that this will terminate all the instances of you process, otherwise you should use the pid.
And if your program upon signaling will be able to comply and try to close the open connections and terminate, it will depend on the program itself.