Exec node error when running terminal commands

If this is a long running script you may want to look at the node-red-node-daemon node as that can pass msg s into stdin of the process and listens to stdout and stderr (But of course assumes your script can accept input while running)

For exec You can tell msg.kill what type of signal to use to stop the process so you should be able to find one that kills it properly.