SBT stop run without exiting

In the default configuration, your runs happen in the same JVM that sbt is running, so you can't easily kill them separately.

If you do your run in a separate, forked JVM, as described at Forking, then you can kill that JVM (by any means your operating system offers) without affecting sbt's JVM:

run / fork := true

From sbt version 0.13.5 you can add to your build.sbt

cancelable in Global := true

It is defined as "Enables (true) or disables (false) the ability to interrupt task execution with CTRL+C." in the Keys definition

If you are using Scala 2.12.7+ you can also cancel the compilation with CTRL+C. Reference https://github.com/scala/scala/pull/6479

There are some bugs reported:

  • https://github.com/sbt/sbt/issues/1442
  • https://github.com/sbt/sbt/issues/1855