How to shutdown ActorSystem by exceptions thrown in main App

Guys how we could shutdown ActorSystem based on throw exception in the main app

object Boot extends App{

  implicit val system: ActorSystem = ActorSystem("Boot")
  implicit val materializer: ActorMaterializer = ActorMaterializer()

  throw new Exception("Boom!!!")


In this snippet actorSystem will be still alive and App will not stop

I guess you can always catch the exception and call


This will effectively initiate the shutdown process of the ActorSystem