Adding sleep cycle to wait for programs that don't exit immediately

It does look like the original had mixed indents, let me know if I misunderstood what you were shooting for. :smile: