Init script: wait for instance to stop

Issue #1115
Makefiles: do not use variables if they are undefined
Cherry pick branch 1115 into v1.7.x

Review 707 by @mlucy