def close():
if state.forked and not state.closed:
sync.quit.value = True
try:
sync.barrier_in.wait(1)
except BrokenBarrierError:
pass
state.closed = True
for p in processes: p.join()