class StoppingExecution(Exception):
    '''Exception class to stop the execution of the program in a jupyter notebook'''
    def _render_traceback_(self):
        return []

def exit():
    '''Exit the program in the notebook'''
    raise StoppingExecution

Register current python as a jupyter kernel

python -m ipykernel install --user --name my_kernel