Throw SparkException and catch it outside to exit instead of system.exit directly.