I've had that experience a couple of times sailing out of Key Largo and Port Canaveral......typically I try to drop the main, leave a little bit of jib rolled out, and either (preferrably, if there is room) run downwind with it or (if running room is restricted) try to point up into it and crank the engine if necessary to keep the bow to the wind. The power in these summer thunderstorms is intense and it can be pretty exciting when one hits. Not uncommon to see winds go from zip to over 50 knots in just a few heartbeats.
Here's a picture of one of the most intense squall I've been in....
....we were coming out of Angelfish Creek in north Key Largo in my old Irwin 25 headed out into the Atlantic as this thing rolled up on us. That's my dad in the picture acting all calm and collected. My two brothers are down below putting on raingear and saying prayers. I had to put the camera away a few moments after I took this - we had all the sails down and were motoring with my little 3.5 hp Tohatsu, and when the wind hit us we heeled over to the point the starboard spreader was not more than a few feet from the water....but she came back up, and we flew downwind (and out toward Pickles Reef) with buckets of rain sheeting down at hull speed with no sails. It was raining and blowing so hard I couldn't see the bow of the boat, and was trying to use a little handheld Garmin GPS to help keep me off the reef. Damn that was fun!
But, about 30 minutes after it came up on us it was gone.......we managed to avoid the reef, just barely, and lesson leard for me was that in that situation (reef close by and downwind of our location, puny outboard with no hope of making significant way into the wind, and in only 10-12 feet of water) it may have been better to try to get an anchor down and ride out the squall on the hook.
That experience was kind of a confidence builder, too. I wouldn't want to experience those conditions for a long duration way offshore, but knowing that these summer squalls move pretty quickly and you can always hunker down and ride them out makes it a lot less scary these days when I'm a few miles offshore and the sky starts turning black.