How can Jupiter eject a comet from the solar system?
Jupiter can eject a comet from the solar system through the process of gravitational perturbation.1
When a comet passes through the planetary region, it experiences the gravitational influence of the giant planets. Jupiter, being the most massive planet, can significantly alter a comet's orbital energy. Through these gravitational interactions, Jupiter can scatter a comet's orbit, changing its orbital period and energy. In some instances, these perturbations are sufficient to transform a previously elliptical orbit into a hyperbolic orbit. Once a comet is placed on a hyperbolic trajectory, it is no longer gravitationally bound to the Sun and is effectively ejected from the solar system into interstellar space.1
This mechanism is a standard part of cometary dynamics; for example, Jupiter's gravity also plays a role in capturing comets into shorter-period orbits or, conversely, scattering them toward the Oort cloud.1