Fix issue with exit code in non-tty mode.

Fixes #3701

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)