Stocks close higher after rocky session