diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy
index defbf109..3ca43d43 100755
--- a/bin/cdist-mass-deploy
+++ b/bin/cdist-mass-deploy
@@ -25,6 +25,23 @@
 [ $# -ge 1 ] || __cdist_usage "[-p] <target host> [target host ]"
 set -u
 
+# trap __cdist_tmp_removal EXIT
+trap killandclean EXIT
+
+killandclean()
+{
+   # i may have been altered outside, just use the current offset
+   while [ "$i" -gt 0 ]; do
+      eval pid=\$pid_$i
+      kill "$pid"
+      i=$((i-1))
+   done
+
+   # Ensure tmp stuff is being removed
+   __cdist_tmp_removal
+}
+
+
 filter()
 {
    awk -v host=$1 '{ print "[" host "] " $0 }'