In order to arrive to this answer you have to assume that the size of the planet and star is negligible compared to the size of the orbit of the planet. When solving this question you have to understand what each symbol stands for:
- $T$ stands for the orbital period of the planets orbit;
- $r$ stands for the semi-major axis of its orbit;
- $GM$ can be combined into the standard gravitational parameter of the sun/star (you actually also have to include the mass of the planet, but since neither masses change you can view $GM$ as the effective gravitational parameter).
The orbits of planets are usually nearly circular, so it would not matter where along its initial orbit the planet stopped, it would always be approximately $r$. While slowing down its velocity the planet would still be in orbit, but it would become more and more eccentric, with its highest point (aphelion or apoapsis in general) at distance $r$ and its lowest point (perihelion or periapsis in general) closer and closer to the sun. When all velocity (relative to the sun) have been cancelled then the lowest point would be zero. When travelling from the highest point to the lowest point of an orbit it would take half its orbital period (due to symmetry). And the new orbital period can be derived from the changed semi-major axis, which can be calculated by taking the average of the highest and lowest point.