Why should asteroid coming towards a star deflect away from star if gravity is an attractive force? I was finding the closest approach of an asteroid  (whose energy is sufficient to exit the gravitational field of the star )so that it can escape the gravitational field of the planet .The asteroid has a velocity and is being attracted by the planet and is leaving the star. Why should it deflect away from the star like this if gravitational force is attractive?
Well I think if I mention the whole question it'll useful so the question is 

An asteroid is approaching a star of radius r . The impact parameter is b . Find the minimum value of b for which asteroid will just escape on falling into the star.

My instructor said the drawing should be    

Why it shouldn't deflect like this?
Instructor said if this happens then it will be orbiting the planet. 

 A: If one thinks of the conic sections which are the solutions of the gravitational equations between two bodies, it is clear that one of the two bodies, the massive one, should be sitting in one of the focuses of the section:

The top image in your answer does not correspond to this. The lower does.
A: This is because of angular momentum conservation.  Basically, the motion in the $r$ coordinate is not only controlled by the gravitational potential $V(r)$ but really by the so-called effective potential
$$
V_{\hbox{eff}}=\frac{\ell^2}{2\mu r^2}+V(r)
$$
where $\ell$ is the angular momentum of the system.  Since the gravitational potential is in $1/r$, it is the centrifugal term $\ell^2/(2\mu r^2)$ that dominates at small distance, and this is a strongly repulsive potential that “pushes back” the particles towards larger values of $r$, preventing the particle from reaching $r=0$ unless the angular momentum $\ell=0$, i.e unless the particle is directly approaching the planet.
When the particle is far away, the $\ell^2/(2\mu r^2)$ term is negligible compared to the gravitational potential so the motion looks purely attractive.
A: The object curves towards the planet: your second drawing is correct.  If you want the asymptotic directions to be as in the first drawing, the object would pass on the other side of the planet.
