cli: refactored re-connecting part after reload/restart

...to void errors (Channel closed) and hangs.

Thanks,
Alexey