Yevamos4: 8
הַחוֹלֵץ לִיבִמְתּוֹ, וְנָשָׂא אָחִיו אֶת אֲחוֹתָהּ, וָמֵת — חוֹלֶצֶת וְלֹא מִתְיַבֶּמֶת. וְכֵן הַמְגָרֵשׁ אֶת אִשְׁתּוֹ, וְנָשָׂא אָחִיו אֶת אֲחוֹתָהּ, וָמֵת — הֲרֵי זוֹ פְּטוּרָה מִן הַחֲלִיצָה וּמִן הַיִּבּוּם.
[If] one performed chalitzah with his yevamah, and [then] his brother married her sister and died, she requires chalitzah but may not be taken in yibum. Similarly, if someone divorced his wife, and [then] his brother married her sister and died, she is released from chalitzah and from yibum.