I want Jupyter Notebook to automatically restart the kernel and Run All [cells] after n milliseconds if a successful execution is not True

I build this application to help me learn math faster:

Rather than understanding why the kernel crashes every 100 executions and requires me to manually restart the kernel and Run All, why isn’t there a feature that lets me specify: “if my notebook does not execute successfully within n milliseconds (say 2 seconds), then the notebook will automatically restart kernel/run all with the same check.”