I had a Maytag microwave doing this. The unit was only 4-5 years old. After testing transformers and magnetron and other interior components I traced the problem to the lower door switch. I tightened the screws just inside the door because one was slightly loose. You could not tell this by opening and closing the door only by applying a screw driver to the screw. I tightened it and everything worked the way it should.
Hope this helps.
Joe