The atmosphere does just "stop" either though. It also forms a gradient. There's not a magic barrier where the atmosphere is and isn't. It just gets gradually thinner and thinner. So in the same way there's a Goldilocks spot in the atmosphere where it's a comfortable temperature without being too cold, there must be another one near the sun.
Besides, heat radiation travels through a vacuum. If it didn't then the Earth wouldn't get heat from the sun at all.