An adaptive mesh refinement strategy to ensure quasi-optimality of finite element methods for self-adjoint Helmholtz problems