Exiting Spark-shell from the scala script
You need to add exit() at the end of your script to avoid stepping into scala REPL.
Helloworld.scala
print("Hello World");
print("Second Line");
print("Bye now");
System.exit(0)
Run above
spark-shell -i helloworld.scala
In version 2.4.3 System.exit(0) is working.