Stocks swung sharply, and the average cost of gas nationwide hit $4.08 a gallon for unleaded and $5.51 for diesel.