How to delete the last UNDO from the list

I wrote a docker that make separation mode in a document. Script creates layer with doutone images.
When I switch off this mode in the docker the layer is removed. But I can make Undo operation and the layer will repair.
I want delete this Undo operation in Undo's list. 
Layer of separation mode must only be created when the button in the docker is pressed.

Is it possible to make this happen? delete the last UNDO.