I need to do this because I am using the WiFiManager library, and to reset it's credentials I need to run a "reset credentials command" and then fully reboot the ESP32 (no, a ESP.restart does not work).
I would do it like this if I was using an ESP8266:
wifiManager.resetSettings(); //reset all saved credentials
ESP.reset(); //restart the ESP
Sorry for not providing this information in the first place!