Close one after one with the exec node the 2 instances of vlc displayed

It's been two weeks since i battle with VLC on raspberry pi 3B to find a command to put in an exec node in order to close this application.
After searching the Raspberry, Debian, Ubuntu ... and VLC (!) forums, as well as this one, I still cannot close VLC other than with "killall vlc" when I would like to be able to close one by one my 2 simultaneous instances of VLC (one for TV, the other for radio).
In fact, I have two problems:
-1- The vlc: // quit command given by VLC does not work or I do not know how to use it.
-2- I found on the forum a way to raise the pid of each instance in the flow to send it as an argument to the closing exec node, but I have the impression that I don't know how to write the right command.
Here is what I do in this Exec node but it doesn't work:
Comand: kill vlc
Argument: PID
Input : SIGKILL, SIGTERM, SIGHUP

To tell you the truth, I don't know anything about programming and I'm new to Nodered.

Any help will be a thousand times welcome and thank you to the leaders of this forum who help newbie like me to progress!

I believe the idea was to replace PID with the numerical process ID of the VLC instance you want to kill. The difficulty here is how to know which one is which. That at least I cannot answer right of the bat...

But when a command is started the process ID can be read and stored to a file for example. Google might give clues.

luckily the exec node will report it in it's status - so you can use a status node to grab it, then store it in context for use later. Or indeed if you have two separate exec nodes for each, then sending a msg.kill to the one you want will kill that one only.

Ah of course if the VLC's are started from Node-RED.

Yes vlc is started from nodered.

I use two exec nodes: one to launch each instance. I therefore have the pid of each one that I recover thanks to a status node + a function node (which I found on this forum) from which I transform the payload into flow.pid with a change node.
Therefore, an exec node with the kill command and the pid as an argument should do the job, but that is not the case.

Does the kill command work with the PID shown in Node-RED if you run it from a terminal window?

I try immediately

I launch vlc from nodered ; the exec node give the pid 1585

So, in a terminal :
pi@raspberrypi:~ $ kill 1585

Answer : bash: kill: (1585) - Aucun processus de ce type

If you have separate exec nodes then you shouldn't need to worry about the pid. Send the kill to the one that started it and it should do it.

What command are you using to start vlc?

That is strange but like @Colin and @dceejay suggested, it'll likely be easier to send the kill signal directly to the exec nodes.

Yes you are all right but I tried this approach because I don't know how to set up the kill sequence.
(I launch vlc with: "DISPLAY =: 0 cvlc")

Could you share your flow where you start the processes so it'd be easier to help with that?

In case you've missed:

This process works on the first kill and not the second

[{"id":"a8f82002.3b703","type":"exec","z":"b15d43aa.8177d","command":"DISPLAY=:0 cvlc http://listen.radioking.com/radio/132073/stream/171985","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"VLC Radio","x":530,"y":3820,"wires":[[],[],[]]},{"id":"8617a53e.732ae8","type":"inject","z":"b15d43aa.8177d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3820,"wires":[["a8f82002.3b703"]]},{"id":"300f27d9.a4ff58","type":"inject","z":"b15d43aa.8177d","name":"","topic":"","payload":"SIGTERM","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3960,"wires":[["2cd1f86c.c7f418"]]},{"id":"2cd1f86c.c7f418","type":"change","z":"b15d43aa.8177d","name":"","rules":[{"t":"set","p":"kill","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3960,"wires":[["a8f82002.3b703"]]}]

I only see one exec node. What the others were suggesting was to create two exec nodes, one for each. This way you can target the kill msg to the one you want close.

If you start two processes by pressing inject twice, I would guess only the one started last will be killed by sending the SIGTERM message.

If you click the inject then run
ps -aux |grep vlc
you will see that it has started two processes. Hitting the kill only kills one of them. I don't know what the solution to that is, if it spawns another process I would have expected that to get killed too.

Maybe the exec node stores only a single PID at a time?

The exec node will not know that the process it started has started another, but I would have expected killing the first to also kill processes it has started. I guess it is due to how cvlc starts the second process.

I use two identical nodes, one for a radio stream the other for a TV stream.
I want them to work at the same time but to be able to stop one of the two when I want.
The stream I sent is that of radio, that of TV is identical

Hmm. So if you start each VLC instance from their respective exec nodes, then trigger the kill message to each exec node, only one will get killed?