A narrow avoidance of something unpleasant:we got him out, but it was a close thing...
It was a near miss as far as I was concerned, a close thing.
It was a close thing for me too, but I was young, and have a healthy heart and I lasted the whole half-hour of assault.
Theodosius also built a second set of walls around Constantinople (it had been a near thing with the Visigoths) and made Christianity the official religion of the Empire.