Rule #1: Have ALL your reef lines run BEFORE leaving the dock... The sail may not be reefed YET but the lines should always be in place.
You just learned the biggest issue with 'coastal cruising', the desire to seek shelter vs run for sea room when a storm approaches. You may have been on edge, BUT A CAT 22 has absolutely no business at sea in a storm. It could have been much worse..