I am going to guess that when you say "crash", you mean that the esp32 reboots with something like the message "Guru mediation error" .
While it is possible that is a software problem or a glitch that can be worked around, it is also true that sometimes this can happen when your power supply does not provide enough power for the esp32. When you turn on the radio it can use a lot more power (it is still small compared to mobile phones, but it uses a lot more power with the radio on - especially when the radio first turns on.
I don't know that is your problem - but I have had this problem in the past when I was using one particular power supply that was enough to support the esp32 with the radio off, but when it turned on - the spike in current was too much for my anemic little power supply and the board would reboot.
So, before investing a time in chasing possible software problems check it with a beefier power supply.