Quadratic Control Law for a Thermal Storage System