"if(pool.stop)" - line 84: Worker will just exit even if there are some jobs to do, should be: if(pool.stop && pool.tasks.empty())