I've never had that particular scenario (still time to put a notch on the headboard!) but my closest was when doing slow speed/stalls. As ever, the one bit of useful blue was bordering the TMA and I spent much of my time chasing 4000ft of clear sky. Combine that with an average student who was struggling with stalls (practically and psycologically) I let my situational awareness dip. At the last moment I noticed a twon that appeared tio be a little cloe and a quick look at the GPS indicated we were about a mile the wrong side of the line. Lights on, transponder checked, a quick 180 and toggling the radio to the freq of the unit concerned (when known/available, I tend to have this selected in one of the boxes). ATC were very good, told me they were generating a bit of a gathering to watch the carnage and that was that.
I learnt about instructing from that.