It can. The boost is proportional to the cos(final exit trajectory in relation to the planet, velocity of planet) -- so if the probe leaves the planet opposite to the direction it goes around the sun, it slows down.
(that is, the probe as whole can still orbit the sun in the same direction as the planet, it just needs to do it slower.