result[i] = quit
if quit:
    pool.terminate()
if __name__ == '__main__':
    N = 50
pool = mp.Pool()
result = [None] * N
for i in range(N):
    pool.apply_async(func=worker, args=(i,), callback=callback)
pool.close()
pool.join()
print(result)
Python Multiprocessing, Pool map - cancel all running processes if one, returns the desired result