Why pilots would leave the cockpit in a short flight?
The cockpit of some airliners lacks a lavatory.


Cockpit layout from AviationKnowledge.wikidot



This is discussed in Skybrary: Flight Deck Security


  Locked Door Flight Safety Issues
  ...
  Physiological Need. Naturally, the need for flight crew to use toilets, access designated crew rest facilities or be supplied with food and drink, requires access through the flight deck door during flight. Procedures for door opening mean that egress and access will take longer with the result that the flight deck crew are not always able to go to the toilet at a time of their exact choice, which may cause them to be distracted and, exceptionally, might exacerbate an existing underlying medical issue in a way that would not otherwise have occurred.
  ...
  Longer term, design change could also ensure that all operating flight crew should be secured on the flight-deck before the passenger boarding doors are closed prior to departure and remain secured on the flight-deck until after the passenger doors are opened at the destination. This would prevent any unlawful entry from the cabin and minimise any unlawful seizure by a single flight crew member.
  To enable this, existing aircraft could be modified and new aircraft designed with all required crew facilities forward of the secure flight-deck door. On short/medium haul aircraft this would require a toilet, safe food &amp; water storage and a reclining crew rest seat. Additionally on aircraft used for long range operations where in-flight relief is required provision of bunk/s.
  This is not a new concept, many long range aircraft already have toilet and crew rest facilities forward of the secure flight-deck door.