Connah's Quay Nomads failed to end their dismal record away at The New Saints but, after establishing a comfortable 3-0 lead, the hosts were guilty of allowing their opponents back in the game.
After conceding one to former Shrewsbury Town youth Mark Cadwallader, they almost paid a high price for their generosity. Lively sub Stewart White had the ball in the net 10 minutes from time only to be ruled offside - a decision which led to Nomads' boss Jim Hackett being red-carded from the dugout by referee Wayne Tregonning.
Bel Alston had earlier fired just wide of the far post and Duane Courtney only denied White with a last-ditch tackle.
There had been little hint that the game might produce a lively finish when the Saints cruised into a two-nil lead inside 20 minutes as Luke Holden produced another man-of-the-match performance down the left hand side, combining well on several occasions with Chris King.
It was Holden who set-up the first, beating his man for his cross to be missed by Alfie Carter but turned in at the back post by Michael Wilde.
Five minutes later, Carter raced onto a through ball and lobbed keeper Paul Pritchard, with defender Alston only able to help the ball on its way as it crossed the line.
Carter could and should have fired a first-half hat-trick, beating Chris Williams to the ball before missing the target, heading wide from King's cross and then being denied when one-on-one with Pritchard.
Nomads' sub Jamie Petrie hit a post soon after the interval before Holden again sparked the Saints into action, feeding Scott Ruscoe whose low cross was turned into his own net by Gary Pinch.
Slack marking allowed Cadwallader to give Nomads a toe-hold and TNS then endured some uncomfortable moments before the points were safely in the bag.
Stats and match report courtesy of welsh-premier.com