Strager has it right except for the part about personal unions...
A has RM with B
A's king dies. There's a (small) chance that A will become the junior partner in a personal union with B. If this happens, A's ruler is now the same as B's ruler and A is restricted in what it can do diplomatically (no RMs, no DoWs, etc.). This state of affairs continues until B's ruler dies. At this point either (1) A gets a new independent ruler and B gets a different independent ruler, and the union is dissolved; or (2) there is a chance that A is inherited outright by B unless A is a country controlled by the player (since that would be game over). If player controls B, the chance of A being inherited is less than it is for B being controlled by the AI (to offset the player's immunity to being inherited). The chance of this inheritance at the end of a PU is greater than the normal chance of being inherited when your king dies and you have a RM with someone.
The only way for the player to avoid the dangers of becoming the lesser partner of a PU or getting into a succession war is never to make RMs (in which case you might also want to consider changing your form of government to a republic).
A has RM with B
A's king dies. There's a (small) chance that A will become the junior partner in a personal union with B. If this happens, A's ruler is now the same as B's ruler and A is restricted in what it can do diplomatically (no RMs, no DoWs, etc.). This state of affairs continues until B's ruler dies. At this point either (1) A gets a new independent ruler and B gets a different independent ruler, and the union is dissolved; or (2) there is a chance that A is inherited outright by B unless A is a country controlled by the player (since that would be game over). If player controls B, the chance of A being inherited is less than it is for B being controlled by the AI (to offset the player's immunity to being inherited). The chance of this inheritance at the end of a PU is greater than the normal chance of being inherited when your king dies and you have a RM with someone.
The only way for the player to avoid the dangers of becoming the lesser partner of a PU or getting into a succession war is never to make RMs (in which case you might also want to consider changing your form of government to a republic).