Optimal control of homoclinic bifurcation: Theoretical treatment and practical reduction of safe basin erosion in the Helmholtz oscillator