fix goroutines leak and exit code

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Signed-off-by: Victor Vieux <vieux@docker.com>
Merge pull request #7301 from vieux/fix_goroutines_leak_exit_code

fix goroutines leak and exit code