My understanding is that bugs are not actually drawn to light, but rather attempt to fly at a fixed angle to light, roughly perpendicular to it. When the light is the Moon, that keeps them flying in more or less a straight line. But when the light is close to them, they turn to keep the light at that fixed angle and consequently spiral in towards it.