Been having a similar problem while activating relays using ESP32's, tried a couple of different dev boards and was getting the same issue on them all, board sends gibberish to the serial port indefinitely and refuses to continue normal operation until reset.
I've managed to get a partial solution with the ESP32-WROOM-32 dev module by reducing the CPU frequency. It now reboots by itself instead of getting stuck. I tested with two of these boards and it appears consistent.
Unfortunately, with a supermini dev board using the ESP-C3 chip, lowering the frequency didn't help.