This works for me (improved thanks to the commenters):
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
-
kill -- -$$sends a SIGTERM to the whole process group, thus killing also descendants. -
Specifying signal
EXITis useful when usingset -e(more details here).