This is designed behaviour and is done as a last option to close the processes on user action.
In AutoPie, each command is run in a specific shell instance but closing the processes inside it cleanly is a chore because Android doesn't provide a simple way to do that. Either with process.destroy() or with the other methods.
I was storing the pids of each of the processes and stopping them manually for some processes and that did work.
I don't think it'll be necessary with the Termux shell instance which AutoPie will be migrating to.
It'll be fixed when the Termux integration arrives.