val timer = new java.util.Timer()
will start a TimerThread
(which extends a standard Java thread and is implemented as an infinite loop), which is running in the background and prevent your application from exiting.
You can run System.exit(0)
at the end of your script to stop all the background threads.
Also have you considered using Akka scheduler instead of Java Timer?