title: How to complete a process in Node JS after executing all the operations
body: <p>I am very new to NodeJS and trying to develop an application which acts as a scheduler that tries to fetch data from ELK and sends the processed data to another ELK. I am able to achieve the expected behaviour but after completing all the processes, scheduler job does not exists and wait for another scheduler job to come up.</p>
  <p>Note: This scheduler runs every 3 minutes.</p>
  <p>job.js</p>
  <pre><code>const self = module.exports = {
    async schedule() {
      if (process.env.SCHEDULER == &quot;MinuteFrequency&quot;) {
        var timenow = moment().seconds(0).milliseconds(0).valueOf();
        var endtime = timenow - 60000;
        var starttime = endtime - 60000 * 3;
        //sendData is an async method
        reports.sendData(starttime, endtime, &quot;SCHEDULER&quot;);
      } 
    }
  }
  </code></pre>
  <p>I tried various solutions such Promise.allSettled(....., Promise.resolve(true), etc, but not able to fix this.</p>
  <p>As per my requirement, I want the scheduler to complete and process and exit so that I can save some resources as I am planning to deploy the application using Kubernetes cronjobs.</p>