There's also at least one case[1] where the locked door itself stopped someone from stopping the crash (the CA had flying experience and Mentor Pilot[2] showed that even someone with no flying experience could be instructed to autoland if they know how to use the radio. If the CA had entered earlier they might've been able to land, though most of the passengers would've still died unfortunately.)
One of the more reasonable theories for MH370 is similar to the Germanwings case. Pilots can refuse access even if the person outside knows the access codes for the cockpit doors.
Unfortunately (as with everything else), even obvious improvements have potential downsides.
1> At 11:49, flight attendant Andreas Prodromou entered the cockpit and sat down in the captain's seat, having remained conscious by using a portable oxygen supply.
Yes, however it's not clear how they entered and why it took them so long (they entered a few minutes before the plane crashed due to fuel exhaustion -- the left engine shut down 50 seconds after he was seen entering the cockpit). It stands to reason that if the door was unlocked they may have been able to enter much earlier, which could've resulted in a very different outcome.
That's why I said "If the CA had entered earlier".