Being in a crappy place mentally and emotionally makes even a small mistake seem like a disaster, and then it's so easy to generalize it to everything about life/your actions/the world....and think you're a failure.
And lighting up the first, and being 'already a failure', makes it easier to light up the second....and those dark nights spiral off. Heart goes out to you on that.
Practically speaking, keep your mouth and hands occupied. Gum. A beverage. A snack. Whatever. Or go someplace where you can't smoke. (Walking for me is exactly when I smoke, so that never helps!) Watch something funny on the computer. Get into a heated discussion where you can't stop typing. Shop online (for 36mg liquid or a new mod!) or anything else distracting.
Just because your stress is overriding your resolution doesn't mean your resolution is weak; it means your stress is strong and your strategy just needs some tweaking. It'll make for a nasty self-hating cycle if you assume you must succeed at quitting exactly with the method you've been trying.
(There's trying a higher mg, snus, an HV device, a therapist, Zyban....Or whatever solution you find. If one doesn't work, try another.)
Hope this isn't too cheesy, but I like Ralph Waldo Emerson:
Finish each day and be done with it. You have done what you could; some blunders and absurdities have crept in; forget them as soon as you can. Tomorrow is a new day; you shall begin it serenely and with too high a spirit to be encumbered with your old nonsense.