function shutdownWorkers (signal) {
  return new Promise((resolve) => {
    if (!cluster.isMaster) { return resolve() }
    const wIds = Object.keys(cluster.workers)
    if (wIds.length === 0) { return resolve() }
    // Filter all the valid workers
    const workers = wIds.map(id => cluster.workers[id]).filter(v => v)
    let workersAlive = 0
    let funcRun = 0
    // Count the number of alive workers and keep looping until the number is zero.
    const fn = () => {
      ++funcRun
      workersAlive = 0
      workers.forEach(worker => {
        if (!worker.isDead()) {
          ++workersAlive
          if (funcRun === 1) {
          // On the first execution of the function, send the received signal to all the workers
          // https://github.com/nodejs/node-v0.x-archive/issues/6042#issuecomment-168677045
            worker.process.kill(signal)
          }
        }
      })
      console.log(workersAlive + ' workers alive')
      if (workersAlive === 0) {
        // Clear the interval when all workers are dead
        clearInterval(interval)
        return resolve()
      }
    }
    const interval = setInterval(fn, 1000)
  })
}
Shutdown all worker processes.
From https://medium.com/@gaurav.lahoti/graceful-shutdown-of-node-js-workers-dd58bbff9e30
@param signal Signal to send to the workers