Yep, that what Stuart says is exactly how it works - the moment you leave the pits, that's a lap.
Think of it this way, if you had actually left the pits IRL, you would have had to go all the way round and come back into the pits again. The game just counts the Escape as that driving right round.
As you're limited to 3 laps, you abort one lap, you only have 2 laps left, so you'd get an outlap and then a timed lap, but you would need a 4th lap to come back in, hence the DQ. It's not so much a glitch, it's just the rules, but it's quite a painful way to find them out, I'm afraid. Still - at least you now know that it's better to take the weight penalty of some extra fuel, than to quit and adjust it, if you find yourself in the same position again.
Personally, I always Practice and Qualify with race fuel in. I'd rather take the slight "penalty" of the weight to have the knowledge of exactly how the car will handle and feel on lap 1.
Another thing you can do in rF is to assign a setup to be loaded by default on a track - I put my race/quali setup to be that "assigned" setup - that way I know I've always got my race setup loaded. This can help a lot for the second quali and race, as the game treats that second set of sessions as a whole new weekend, effectively a new track, and will load whatever it thinks is the default set for that track.