Often, with the force provided by the ejector pins.
The part of the injection molding process that deals with getting the finished part out of the mold cavity or off the mold core is called ejection. Use of that word may improve your search results.
Sometimes, the mold features that produce re-entrant surfaces are moved out of the way by cams, at some expense in money, complexity, and cycle time.
Sometimes, the part can be deformed plastically while it is still hot, removed by force, and then cooled in a simple fixture.
Example: I had a claw molded with internal teeth. It could be pulled off of the core with a gloved hand, during which process the claw arms were bent outward. The operator bent them back in and secured them in place with a rubber band while the part cooled to room temperature.
Of course, in the case of bottlecaps, the core unscrews to eject the part. That's why the OD is knurled or polygonal; making it easier to grip the cap is pretty much accidental.