bugfix: correctly wait for CMD to terminate