Python crashes Grasshopper and Rhino

Whenever I run any kind of code on the python editor in Grasshopper, no matter how simple I make it, Grasshopper and Rhino both go unresponsive forever and wont even close when I try to close them, except through the task manager. I have tried adding a wait command to the code that it runs, but it still fails, and never generates any crash logs. How can I get it to not crash and to just run the code properly?

Can you execute Python code from the EditPythonScript command?

Is it possible that there’s a blocking dialog hiding in the background?