In the US two people must be in the cockpit at all times. If one of the pilots needs to use the bathroom, a flight attendant has to take their place in the cockpit until the pilot returns. This prevents a suicidal pilot from taking down a plane (or makes it much harder anyway). This wasn't a requirement on Malaysian Airlines at the time. (I don't know if the regulations have since been updated.)