Do You have the model number available?
When it shuts off does the control go blank at the same time?
I have seen this quite a few times, the Magnetron (transmitter in the microwave that heats the food) has a gasket on it, the magnetron emmits a radio frequency to cook/warm Your food. When this gasket leaks the signals hit the back of the control and cause it to shut down. The gasket can only be purchased with the magnetron, and the board rarely survives the abuse from that leak. You more often than not need to replace both parts, allthough You can start with the Magnetron and see what happens, the good news is that if the microwave was purchased less than 5 years ago some or all of the repair could be covered by the MFG.
Let Me know what You find in Your owners manual for warranty coverage and if You would like to continue with fixing the Microwave Yourself.
I do want to warn You, the circuit that needs repaired (Magnetron replacemnt) is producing 4000 volts of direct current, This not only hurts if You become the conductor but also is likely to be fatal and it can hold a charge so even if You unplug the unit You can still get shocked....bad.