Gherkin step result

I want to use Gherkin “hook_after_step” to find out if the step executed passed or failed. Based on that result, if previous step passed I want to continue to next step otherwise I want to quit from the scenario.
How can I implement this ?