Code MEL for a while and you'll soon learn that Maya does not provide a method for terminating a runaway script. If you lose communication with Maya's UI, you're pretty well resigned to killing its task.

The abortTest function provides a pro-active method for killing non-responsive scripts. It tests for the presence of a file called "DIE" in your "$HOME/maya/" directory and returns a non-zero value if this file exists. The "DIE" file is deleted after detection.

Insert the following code in your MEL script, for example in a time-consuming for() loop:

if ( abortTest() )
  error( "Aborted externally!" );

Now if this script gets out of control, you can force it to exit by creating the DIE file from a shell:

touch ~/maya/DIE