by a hair's breadth
By an extremely short distance or slim margin of time. They're just about to close the gates! It looks like we made the flight by a hair's breadth. The race was neck and neck till the very end, but Sally won it by a hair's breadth.