What to do if your script needs to kill all processes that it started? Just kill everything that has same parent as your current shell ($$):
$$
#!/bin/bash … kill `ps -ef | awk '$3 == '$$' {print $2}'`