The practical rule
Priority one after entry: prepare and submit the residence-permit materials, online and in person. Until you have your passport back and the permit in hand, avoid locking in any non-refundable international flights or hotels.
Genuine emergency? If you truly must leave and cannot delay, do not book and hope. Contact the handling immigration office, explain the situation and ask whether they can issue a receipt or temporary-travel arrangement. This is not a guaranteed entitlement — it is granted case by case at the window.
And a hidden risk: even if you slip out during processing, re-entry and completing the residence-permit step will be blocked, forcing a full replan. It wastes time you cannot get back.