title: How to trigger application shutdown from a service in Nest.js?
body: <p>I'm looking for a way to trigger application shutdown from a service in Nest.js that will still call hooks.</p>
  
  <p>I have a case when I'm handling a message in a service and in some scenario this should shutdown the application. I used to throw unhandled exceptions but when I do this Nest.js doesn't call hooks like <code>onModuleDestroy</code> or even shutdown hooks like <code>onApplicationShutdown</code> which are required in my case.</p>
  
  <p>calling <code>.close()</code> from <code>INestApplication</code> works as expected but how do I inject it into my service? Or maybe there is some other pattern I could use to achieve what I'm trying to do?</p>
  
  <p>Thank you very much for all the help.</p>