Main thread blocking spawns

I came to know about the reason of my program’s doing nothing was that
the main thread keeps on running in a loop of sleep to stop killing
spawned children when main thread exits but the spawned children gets
stuck to one specific instruction, this is not expected… will the use
of join should solve this problem or will I need something else?