We almost missed our flight, it came right down to the wire. The traffic on the way to the Vancouver airport was gross, and we had to run to our gate.
This phrase refers to races where the winner is determined by whoever crosses the finish line first. Think of horse racing and foot races. A string is stretched across the finish to help the judges see clearly who crosses first in a close race. That string is called the wire or tape, the winner is the one who breaks the wire first.
The wire is actually string, tape, or paper and not a metal wire at all. No need to be concerned about those horses tripping and getting themselves caught in the wire. Hence down to the wire means the event is not decided until the very end of the event.