I have advocated (as annoying as it is) for a cabin crew to be present in the flight
deck whenever a pilot is out of the cockpit. Very hard for a pilot to deny entry to
his companion if the cabin crew is at the door and can open it in a second if the
sole pilot at the seat starts to get out of his seat.
Pilot suicides do occur.