What happened is a common thing. You should be prepared for the coming lulls. Look upwind to see them coming. When in a lull, I bend my knees and hang on a boom, and transfer my weight back to above my board. Maybe others do it in a different way, I don't know.
If you do fall backwards while hooked in, don't release the sail until you are in the water, then unhook and swim from under the sail in one direction. Don't change it
Being under the sail I swim forward to the mast, find it with my hands and use it a support and reference point when to swim up.
Often I get unhooked somehow before I fall into the water so I hit the water with the sail above me in the air which lets me waterstart immediately
When falling forwards while hooked in do not release the sail for a different reason. Feet remain on the board, too. You stay in the push-up position. Thus you cannot tear the sail with your body.