Dishwasher issue's

All cycles work on dishwasher. here’s the problem , the last 4 minutes of wash cycle it throw’s the GFI plug out.then I unpluged the washer , connected it to an extension cord &plugged into another GFI outlet & the cycle would not count down.it kept running, had to press drainoff to get it to stop. I also had the drying cycle turned off. any help appreciated. Thank’s ,Jay