That's correct you need to work out the time it takes the relay to react and account for that in the delay
if it reboots you're doing something wrong
maybe something like putting a task into suspend while releasing it from suspend.]
that would cause a crash
just play with the first one first
then later you can play with the second one
You can find a good read on the use of vTaskDelay on this thread
we have dealt with this subject in massive depth
https://forum.arduino.cc/t/esp32-getting-to-the-core-of-the-task/1161303/1
you will find lots of answers and experiments there