[fixes #1083] ensure the CLI exits with the correct status