Even if a team wants you to stay, you do not have to. YouAreStillAnIndividual. You can explain the situation and expect them to handle it. I get in early and leave early. People only see me leaving early. Sometimes they say something. Clearly I'll never be TheHero, but that's ok.
It's not necessarily always okay. If you always expect others to just "handle it" whenever your personal desires conflict with theirs, you are not playing the part of a team member responsibly. Whether anyone says something or considers you to be a hero is not important - people know whether you are doing your job, no matter what time you come in or leave. But if your desired work hours or work habits are incompatible with those of the team, it may be best to leave that team.
I doubt most people know who is doing the job or the people who fuck up wouldn't be the heroes, would they? As for staying late just for image, I guess TheyCanFireMe. That's just too stupid for words.
Yes, staying late for image would be really stupid. But what about staying late to actually do something useful? No-one should be hung up on "image" - that is, no-one should care whether they are seen as heroes or as deadbeats. Stop worrying so much about what others think, and just do your job well. If it's a good team, good work will be recognized, regardless of what time of day it is done (in fact, a good team will work normal hours most of the time). If it's a bad team, you should leave it or take some proactive steps to improve it. That's the responsible choice an individual should make. Pretending to be a member of the team, without actually feeling any loyalty or responsibility to it, is just dishonest.
Part of being a professional is realizing you must do a good job because of your own internal motivation. It's likely nobody will recognize you or otherwise praise you. If that's why you do a good job, get a different job. Easy to play that JustLeave angle, isn't it?
The unresistable reference to LifeOfBrian...
BRIAN: Look. You've got it all wrong. You don't need to follow me. You don't need to follow anybody! You've got to think for yourselves. You're all individuals!
FOLLOWERS: Yes, we're all individuals!
DISSENTER: No, I'm not.