How to kill the execution of a notebook on specyfic cell?

Braxx
Contributor II

Let's say I want to check if a condition is false then stop the execution of the rest of the script.

I tried with two approaches:

1) raising exception

if not data_input_cols.issubset(data.columns):
  raise Exception("Missing column or column's name missmatch. Please check input data has a valid schema: " + str(data_input_cols))

Even if the exception is thrown it still continue running the next cell

2) exit notebook

if not data_input_cols.issubset(data.columns):
   dbutils.notebook.exit("Missing column or column's name missmatch. Please check input data has a valid schema: " + str(data_input_cols))

Here only the message is thrown. Again the rest of the cells are executed

TIA