I have been caught in many of those. In S Florida, it is just a way of life this time of year.
Always keep an eye on the sky around you. They build up quick, come on you quick, and leave quick. First thing to do is throw on lifejackets too. Remember to reef in your sails or go with just a reefed Jib. I once owned a Catalina 250 and it does pretty good with just a reefed jib, and it is easier to control. If you are inside a bay, make your way to the middle until you can get a feel for where the wind will come from, then make a b-line for that shore. Caution, those storms do sometimes shift winds... but I typically have found they blow from one direction.
Stay away from the mast. Lots lof lightning.
If you are in an area where you can anchor safely, do it and get it set. Keep your motor running and make sure you have put out lots of extra rode.
They are not that bad once you get used to them... and it will make you a better sailor.