title: Stop nodemon programmatically after run
body: <p>I'm working on an API that runs in the background, we have some helper methods that need to be launch as such <code>nodemon --exec babel-node commands/router.js</code> to display all routes for instance.</p>
  
  <p>Note that <code>node commands/router.js</code> cannot work as we need babel</p>
  
  <p>At the moment, the method runs without problem but I need to stop nodemon from running after execution. I understand that nodemon is supposed to keep running after execution but our project is designed as such and I need to use nodemon for execution and then kill it.</p>
  
  <p>How can I kill/stop nodemon after run?</p>
  
  <p><strong>Code</strong></p>
  
  <p>package.json</p>
  
  <pre><code>{
    ...
    scripts: {
      "start": "nodemon --exec babel-node index.js",
      "router": "nodemon --exec babel-node commands/router.js"
    },
    ...
  }
  </code></pre>
  
  <p>router.js</p>
  
  <pre><code>const script = () =&gt; {
    // Fetch and display routes
  }
  
  script()
  </code></pre>