Generalized Finite-Horizon Linear-Quadratic Optimal Control