Doing the right thing quickly often makes the difference between getting off unnoticed or having the embarrassment, and possibly danger, of drying out. The easiest way off is usually by the same route you went on.
On a weather shore:
back the jib and come about immediately
if the wind is aft of the beam, gybe
On a lee shore:
drop of luff all sails at once, to prevent being driven further on.
If the tide is rising; then time is on your side and your main danger is being driven further ashore.
Set an anchor at once.
If the tide is falling; you will not have much time
Set a kedge (see Fig. 7). Place the anchor first in the dinghy with the flukes over the stern. Then flake out the chain and the warp so it runs out freely as you row toward deeper water.
If the yacht’s rudder is free, then kedge off stern first.
If the rudder is jammed, you may need to pivot the boat. To do this take the kedge line through a block at the bow and then to the winch.
Heeling the yacht may reduce the draft enough to free the boat. Support the boom with the main halyard, and swing crew weight outboard. You could even use the partly swamped dinghy for added weight.
If time allows, set a second kedge to increase the pull, or to assist with heeling. Lay out the second anchor just aft of abeam, and attach the warp to the halyard. (see Fig. 8). The spinnaker halyard is probably best as the main and head sail halyards are not designed to take side loads.
If the above actions are unsuccessful, and it is apparent you will have to wait for the next high water, the immediate actions are:
check the seabed beside the boat for rocks or other obstacles
close all seacocks
seal fuel and water tanks
check whether your batteries can take the heel without spilling. If not, chock or move them so they will be more level
secure galley and locker equipment that might be damaged
pump the bilges while the boat is still afloat
heel the boat towards high ground - normally the opposite way to which you have been trying to kedge off
as the water recedes, protect vulnerable parts of the hull from damage by obstacles on the bottom
at low water, lay out your strongest anchor in the direction of deep water