We address the traffic light control problem for multiple intersections in tandem by viewing it in a stochastic hybrid system setting and developing a Stochastic Flow Model (SFM) for it. Our model includes roads with finite vehicle capacity, which may lead to additional delays due to traffic blocking. Using Infinitesimal Perturbation Analysis (IPA), we derive on-line gradient estimators of an average traffic congestion metric with respect to the controllable green and red cycle lengths. The IPA estimators obtained require counting traffic light switchings and estimating car flow rates only when specific events occur. The estimators are used to iteratively adjust light cycle lengths to improve performance and, in conjunction with a standard gradient-based algorithm, to seek optimal values which adapt to changing traffic conditions. Simulation results are included to illustrate the approach.