Actors are usually deployed in hierarchies. This layout brings flexibility to the actor system as well as other features, such as separation of concerns (where an actor will only care about the business logic and the parent would deal with the error handling through the supervision strategy). This layout also has repercussions when stopping actors. When a given actor is terminated, then all children actors of that given actor will also get terminated in a non-deterministic way. However, this default behavior might not always be the desired behavior for your use case. This might be the case when shutting down actors connecting to external services.
In this recipe, we will cover how to do ordered termination of actors to cover scenarios where some actors need to terminate before others. To demonstrate this, we will create a ServicesManager actor that will act as the...