When the light turns red, a queue grows backward from the stop line, even though every car is driving forward. When it turns green, a second wave runs back through the queue as cars start moving, and it's faster than the first one, so it catches the back of the queue: that's when the queue is gone. Both speeds come straight off the flow-density curve, and they tell you how much green time the light needs.