"The laptop also doesn't do this when running on the battery it's only when connected to the mains."
I had an Hp laptop that had a similar problem. It was a hardware fault. The battery / battery charger had developed a fault and was producing excess head - causing the machine to switch off when on mains power. There was an eventual recall on my models power adaptor / charger.
Have you checked on the manufacturers web site to see if this is a known issue?
CD