Can I cancel a running editor script?

I'm learning to use editor scripts and in the process I have gotten Unity stuck. My script had an error in it (referencing a destroyed object) but I had a progress bar going when this error hit and now I can't do anything.

Is there a way to cancel a running script or am I stuck force quitting Unity?

As far as I know there is no way to kill an editor script. I've had to kill Unity many many times in the process of making one of my editor importer scripts.

I'm not 100% sure I understand correctly, but here's my train of thought.

You execute a code line which causes a crash but can not determine the cause of the crash because the program stops freezes and shuts down instead of stopping at a line?

If so in console window just activate the pause on error mode and on that specific code line add a Debug.LogError(/contents/); and also when fixing it use either construct I use a great deal of times.

if(GetComponent<TypeOfComponent>() != null) //Can I get it?
{
    myComponent = GetComponent<TypeOfComponent>(); //Get it!
}

void Update()
{
    if(someEventOccured) //I need to use it
    {
        if (myComponent != null) //If it is here
        {
            myComponent.DoTheMagic(); //Do stuff with it
        }
        else //If it's not here we have a problem
        {
            //Report the problem
            Debug.LogError("Missing myComponent in 'this script'");
        }

        //Or a try catch block with 
        try //Execute code only if it works follow *** for reference
        { 
            myComponent.DoTheMagic(); //Do stuff with it 
        } 
        //Something went wrong so catch what did
        //Knowing the type of problem is critical for this construct
        //The type is specified inside the catch ( ) block
        catch(MissingComponentException e) 
        {
            //e is now the object containing the error information
            //it's common to choose that name but you could put "IlikeCats" there aswell
            Debug.LogError("Missing component in 'this script'" + e);
        }
}

I just hope I understood your question properly , if not I can always toss this answer in the bin ^^

Hope it helps!

(reference here)