code: function listenExit(handler) {
    const onSighup = () => {
      process.exit(1 | 0x80);
    };
  
    const onSigint = () => {
      process.exit(2 | 0x80);
    };
  
    const onSigterm = () => {
      process.exit(15 | 0x80);
    };
  
    const onError = (err) => {
      if (err && err.stack)
        console.error(String(err.stack));
      else
        console.error(String(err));
  
      process.exit(1);
    };
  
    process.once('exit', handler);
  
    if (process.listenerCount('SIGHUP') === 0)
      process.once('SIGHUP', onSighup);
  
    if (process.listenerCount('SIGINT') === 0)
      process.once('SIGINT', onSigint);
  
    if (process.listenerCount('SIGTERM') === 0)
      process.once('SIGTERM', onSigterm);
  
    if (process.listenerCount('uncaughtException') === 0)
      process.once('uncaughtException', onError);
  
    process.on('newListener', (name) => {
      switch (name) {
        case 'SIGHUP':
          process.removeListener(name, onSighup);
          break;
        case 'SIGINT':
          process.removeListener(name, onSigint);
          break;
        case 'SIGTERM':
          process.removeListener(name, onSigterm);
          break;
        case 'uncaughtException':
          process.removeListener(name, onError);
          break;
      }
    });
  }
docs: Listen for exit.
  @param {Function} handler
  @private