Much closer than stars are the distant lamps (polychromatic or monochromatic), say 2 to 3km away, also twinkle. this cannot be related to change of index of refraction due to temperature's variations , since the frequency of this twinkling does not vary strongly with air turbulence.
the accepted explanation for this is: light is formed of photons (light particles) which spreads out from the source in all directions, thus as the distance increases, the spherical surface area increases with the square of the radius, hence photon's flux decreases, and the number of photons reaching the eye become less frequent. at the times of absence of photons entering the eye, the image of the source disappear.
Moreover, it is known from astronomy, that forming an image of a very far celestial object needs long time, and large lenses or mirrors. this shows that: in order to form an image, an enough number of photons is needed, which requires long time to collect them.
By Sami Kheireddine