A couple of pictures of the set up would help. In the meantime;
1. What size boat?
2. What shaft size are you using?
3. What size stuffing tube?
4. What is the gap from stuffing tube to coupler?
5. What rpm are we talking about?
6. Is everything balanced, including the prop?
7. Which way does the boat flip, end over end, sideways or how?
I agree with Martin that you are introducing an unnecessary complication with the UJ. The flex shaft is exactly that, flexible and can be subject to whip. With the UJ in the loop it could well be causing your vibration and consequent destruction.
I can only assume you are running the boat at max speed for to long a period to make it randomly flip over, thats a common issue with fast boats is that to much speed will make them unstable in the water .
I cannot agree with this as it is all down to set up, too long is not a problem , too fast for the hulls capability can be as can too fast for the actual conditions.