When a warning is issued, the command continues. When an error is issued, the command exits with status 1. So, you should use WP_CLI::error() here, which automatically calls `exit(1)`.