Could also be your full water switch at bottom of machine if it is a condenser. This stops spillages but these switches can give trouble.
I am not an appliance engineer but I would guess there to be an over-heat safety cut-out in your machine. To turn the power off if things get too hot - to prevent a possible fire.
I also guess that the safety cut-out is causing your machine to stop. Why?
Perhaps the safety cut-out is defective but more probably the fan that blows air over the heating element is gummed up and the air flow-rate is slower - the air has more time to heat up - the cut-out operates. Look to your blower.
Of course all this is pure guesswork...
We may have found other answers which could help you.