Protecting the stability of the electroweak vacuum from Planck-scale gravitational effects