Moved System.exit(0) out from run method.
Throw SparkException and catch it outside to exit instead of system.exit directly.