Flight is the most energetically costly activity that animals perform, making its optimisation crucial to evolutionary fitness. Steady flight behaviours like migration and commuting are adapted to minimise cost-of-transport or time-of-flight, but the optimisation of unsteady flight behaviours is largely unexplored. Unsteady manoeuvres are important in attack, evasion, and display, and ubiquitous during take-off and landing. Whereas smaller birds may touchdown slowly by flapping, larger birds swoop upward to perch - presumably because adverse scaling of their power margin prohibits slow flapping flight, and because swooping transfers excess kinetic to potential energy. Landing is especially risky in larger birds and entails reaching the perch with appropriate velocity and pose, but it is unknown how this challenging behaviour is optimised. Here we show that Harris' hawks Parabuteo unicinctus minimise neither time nor energy when swooping between perches for food, but instead minimise the gap they must close under hazardous post-stall conditions. By combining high-speed motion capture of 1,592 flights with dynamical modelling and numerical optimization, we found that the birds' choice of where to transition from powered dive to unpowered climb minimised the distance from the perch at which they stalled. Time and energy are therefore invested to maintain the control authority necessary to execute a safe landing, rather than being minimized continuously as they have been in applications of autonomous perching under nonlinear feedback control and deep reinforcement learning. Naïve birds acquire this behaviour through end-to-end learning, so penalizing stall distance using machine learning may provide robustness in autonomous systems.