^The same thing happens to me because of my sleep patterns.
I regularly go without sleep (this week I think I slept once every second night), because I'm terribly undisciplined and easily distracted. Now when the body is over-fatigued, it does something called "micro-sleeping", where the brain shuts down for a few seconds every so often. Usually the person is completely unaware he is losing consciousness and is able to continue with his day, although of course it's extremely dangerous while driving.
Because I don't sleep, I often microsleep during the day - MID SENTENCE WHILE TEACHING! And the worst thing is it completely screws up my short-term memory as well so when I wake up I have absolutely no idea what I said earlier and am left staring blankly into my students' faces. Even worse, I find my subconscious often takes over while micro-asleep such that when I wake up I find myself in the middle of a sentence about something extremely unusual and unrelated to the topic. I've had quite a few lessons where my students stare at me round-eyed in horror. Once I woke up to find myself talking about quavers and crotchets having a party.
The absolute worst thing is, when I'm just coming out of it, I have no idea whether what I'm saying makes sense - my brain is severely debilitated and it takes me about 20 seconds to tell. This has made me increasingly paranoid. Like you I'd just stop talking while my students panicked.