Note that a closely related cousin of this is post run fainting. Many runners will clock out just after stopping the run. Many will get that feeling a few moments later. It is created due to dilated vessels and a heart rate that has started to return to normal. You will generally experience these in training if they happen to you. Best word of advice is to grab something as you feel them hit.
Being a "fainter" (when really sick, when super-hungry, and most recently when I messed up my run, nutrition, hydration AND caffeination all at once), I'll tell you that the BEST thing to do if you feel the feeling is to just sit down. Wherever you are at the end of the race (assuming, of course, you're in a safe place), just get on your bottom.
For me, the fainty feeling is that my ears almost close off; things get progressively quieter, and I usually think something like "ooh I'm really woozy". The instant I think those things, I need to sit down. Usually sitting makes it go away. A few times in my life I ignored it, and ended up on the ground anyway, just not of my own volition. So don't ignore it.
OP, I like that you asked here. I'd rather ask a group of people who know what it's like first-hand, rather than hope you find the right doctor who didn't miss that week of medical school 30 years go when they talked about these things. Or, most likely, it wasn't covered at all in medical school 30 years ago. Heck, last time I checked medical school courses, they have a whopping TWO nutrition courses, and that's at the best schools, and it's general nutrition. Guess what? I've had two nutrition courses, too!
I'd much rather talk to a group of people who have "been there done that", rather than put all of my being into the hands of ONE almost-certainly flawed MD or ND. So good for you for asking!