kill_and_wait: Fix logic, only sleep if pid still running