Quadratic Bolza problems in static spacetimes with critical asymptotic behavior