One who no more than barely catches a train, who has hardly settled himself in a theater seat before the curtain rises, who in a moment more would have been too late for whatever the event might be, is said to be “just under the wire.”
The expression comes from the racetracks. The winning horse is the first to go “under the wire, the “wire” being a figment of the imagination, but denoting the exact line that marks the finish of a race.
But in many races, though the winning horse receives the major part of the purse, the second, third, and often the fourth horses are also “in the money”, that is, receive a share of the prize.
Thus a horse that just noses ahead of the fourth, or sometimes fifth, horse to cross the finish line is “just under the wire.”