To enable cleanup, open the spark shell and run the below commands:
val sc = new SparkContext(new SparkConf())
./bin/spark-submit <all your existing options> --spark.worker.cleanup.enabled=true
Note that this will work only for stand-alone applications