Quick rule about racing. If the finish line is in sight and you're not participating in a bunch sprint, you need to ride as hard as you can until you cross the line. No sitting up, no thinking you have it, or thinking they won't be able to catch you. Just bury your head, suffer for another 60 seconds, and leave nothing on the road. I know it hurts, I know you've been racing for all of 30 something miles (if you're a 4) and you're tired, but you can afford to push just that much harder until you cross the line. This isn't about pride, and sportsmanship (which are both important), it's about not losing places because you gave up when there was only 30 seconds left in the race.
If you don't ride hard enough to black out just a little, and then you get pipped at the line and end up getting a place lower than you thought you deserved, you don't get to complain about it. You sat up, dude. Thinking you were secure in Xnd place caused you to get (X+2)th. That sucks, but it's entirely your fault.
If you're already in 29th, and sitting up is going to get you 31st, then no problem, do whatever you need to stay upright. But if you're near the pointy end of the race, never never never let up until the finish line is behind you. Or you're going to get made fun of. Anonymously on the internet, and otherwise.