Sammy's decision to quit in the middle of his shift at the A&P is not necessarily driven by a single factor.
It is important to consider when the story was written. Social mores and relationships between teenagers and adults were beginning to change when Updike wrote the story in 1961. Sammy's decision to stand up to Lengel when he mistreats the girls in the grocery store is fueled at least in part by his growing dissatisfaction with the homogeneous, suburban consumer culture exemplified in national brands like A&P. Sammy considers the other customers "sheep"—thoughtless followers with their HiHo crackers and herring snacks. His rejection of the A&P and what it embodies would, in this case, precede the girls' arrival.
Sammy's decision to quit could also be a manifestation of his transition from boyhood into manhood. He could be standing on principle while at the same time hoping for approval and gratitude from the girls. He could be rejecting Lengel's values—that girls must not wear bathing suits in public. There likely is not a single reason that motivates Sammy, and Updike likely did not want Sammy's decision to be simplistic and transparent to the reader.
The answer above may be correct, but I do not think that this is really what Sammy is thinking. To me, he is not thinking about what he wants to be in the future or anything like that. When I read this story, I go back to being a teenager and I know what I would have been thinking in Sammy's place -- I would have been thinking that maybe I could impress these girls and get one or more of them interested in me.
I think that teenage boys are (or at least were in my day) way more interested in the slightest possibility of sex than in what their future might hold. Because of that, I think that Sammy is being purely driven by hormones and mental pictures of Queenie, in particular" as his girlfriend.
My only evidence for this (other than my own memories) is this line:
The girls, and who'd blame them, are in a hurry to get out, so I say "I quit" to Lengel quick enough for them to hear, hoping they'll stop and watch me, their unsuspected hero.