I once almost ran out of gas...when I filled up, I basically put in the amount that was the usable fuel for the aircraft.
It was a stack-up of unusual events. Flew to a fly-in with two other airplanes. When we were ready to leave, the line to the gas pumps was so long we skipped it and left. Landed at an intermediate private field on the way back to view some property. One of our party had an engine go rough on takeoff and aborted. The first plane off didn't see it happened, and kept going. I went back, landed, and killed a couple of hours trying to help figure out what was wrong.
Heading home, it was evening (this was on a weekend). I wanted gas; there were two airports on the way but it was so late I figured the FBOs would be closed. I was NORDO, so couldn't call and ask if they were open. Dropping in to check would waste even more gas.
There's a kind of self-hypnosis that happens in this kind of situation. The engine has its usually smooth drone, like it'll go on forever. It's hard to imagine that it ever will stop.
There was one more airport on the way...but it was a controlled field, and I didn't have a radio. Made it home, but put 14 gallons into a nominal 16 gallon tank.
I, too, had been one of those idiots who had said, "I'll NEVER run the airplane out of gas." I know different, and this has given me some armor against it happening again.
Anytime I think of pushing fuel, I remember that hollow-stomached feeling watching the top of the fuel-tank-gauge wire bouncing against the top of the tank...and then watching it ground solidly with no movement.
Go ahead and thrash me, folks...you won't say nothing I haven't said to myself in the 25 years since this happened.
Ron Wanttaja