Waitforexits

This makes the reconnect logic work a bit better by waiting on clean shutdown before proceeding.

/cc @fraenkel