title: How to save data from actors on system shutdown
body: <p>For example I have following actors: <code>Player</code> and <code>GameRoom</code>.</p>
  
  <p><code>GameRoom</code> holds players with scores. When user left(terminates), we save player score in database:</p>
  
  <pre><code>  class Player extends Actor {
          ...
    }
  
  
    object GameRoom {
      case object Join
    }
  
    class GameRoom(database:ActorRef) extends Actor {
  
      type Score = Int
  
      var players: Map[ActorRef, Score] = Map.empty
  
      def receive: Receive = {
        case GameRoom.Join =&gt;
          context.watch(sender())
          players = players + (sender() -&gt; 100)
        case Terminated(player) =&gt;
          players = players - player
          database ! SavePlayerScore(...)
      }
  
    }
  </code></pre>
  
  <p>But what if I want to kill jvm process (<code>SIGTERM</code>)? In that case i have no way to save all users score to database on shutdown. </p>
  
  <p>Any hints how to implement needed behaviour? </p>