How to kill subprocess of a shell
How to kill subprocesses of a shell
In bash $$ will get you current process id.
You can use pkill -P $$ to kill all subprocess of the current shell.
-P, --parent ppid,...
Only match processes whose parent process ID is listed.