To elaborate just a bit. You have the EXTRACTOR attached to the slide that pulls the spent round out of the chamber as it moves backward. As it moves the round contacts this part, the EJECTOR which causes the round to pivot out ejection port on the slide.
Load a SPENT ROUND into your Glock and pull the slide back slowly. You can see it in action.