Cancel Batch process

I have some macros to run in all the parts in the folder. While doing that, I need to cancel that with cancel button.I already have cancel button with my form, and i used "End "  code to unload the form. Is there any codes available for that.

Thank you

SolidworksApi macros