You should be steering that slalom course in gusty winds, that's normal.
With every big gust, you have to bear off and run deeper, or, as you did, you'll flip, even if you are flogging the spinnaker, it's still a lot of drag up there pulling you over.
So just bear away in every big gust, and go fast with the spin trimmed in.
You should be looking back over your shoulder all the time, looking for the next gust so you'll be ready to bear away when it arrives. Do not wait until you are already nearly flipped over.