by the way, because of this, whenever i use the MaskedStretch script i will usually clone the result, then undo all the way back to before i did the masked stretch on the original image, and then do something else, like inverting it or some other junk operation which i then undo.
that will clear out all the history associated with the masked stretch, which can be 50-100 images depending on how you run the script.