Over time dust accumilates not only on the computer, and inside it. But in rare cases it will accumilate where you plug your charger in. I had a case of all three happening. When it overheats like this the dusts cause random parts of the computer to stop working when to hot. The best thing to do is take it to a shop. Because the computer case needs to be opened, cleaned, and in some cases the charger port needs to be replaced. Most of this has already been said but this is the true and full explination.
If you are having this problem and you take great care of your laptop, then it is the barrery or the charger port. If its a new battery it needs a new port and needs to go to the shop. Saddly in my case I figured this out when I sold my laptop to the shop and they explained this to me after I baught a new one....... no returns, no refunds. X.x