How to shut down the Akka Actor system (ActorSystem)

This is an excerpt from the Scala Cookbook. This is a very short recipe, Recipe 13.7, “How to shut down the Akka Actor system.”


You want to shut down the Akka actor system in a Scala application, typically because your application is finished, and you want to shut it down gracefully.


Call the Akka shutdown method on your ActorSystem instance:

object Main extends App {

    // create the ActorSystem
    val system = ActorSystem("HelloSystem")

    // put your actors to work here ...
    // shut down the ActorSystem when the work is finished


Update: I haven’t updated this example yet, but the shutdown method was deprecated and then removed, and has been replaced with terminate. See the ActorSystem documentation for more information.


When you’re finished using actors in your application, you should call the shutdown method on your ActorSystem instance. As shown in the examples in this chapter, if you comment out the system.shutdown call, your application will continue to run indefinitely. In my SARAH application, which is a Swing application, I call actorSystem.shutdown when the user shuts down the GUI.

If you want to stop your actors before shutting down the actor system, such as to let them complete their current work, see the examples in Recipe 13.6, “Stopping Actors”. 13.8. Monitoring the Death of an Actor with watch

The Scala Cookbook

This tutorial is sponsored by the Scala Cookbook, which I wrote for O’Reilly:

You can find the Scala Cookbook here on

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.