Dust is a great insulator and stops things (like your computer) being kept cool.
If you don’t keep it cool then it runs for a while and then suddenly switches off and then often won’t start and stay running unless you leave it a while to cool down. Sound familiar?
Dust may be your problem.
Open up the machine and use a large, fluffy paintbrush to clean out all the dust you can see. Especially round the processor fan. (don’t use a vacuum cleaner – it’ll kill the machine!).
You may even need to take the fan apart to clean it properly but then you’re better off calling me because there’s “technical stuff” in putting it back together involving thermal paste and such.