On The Global Stabilization of Locally Convergent Algorithms for Optimization and Root Finding