I am assuming that you have control over the InviteFriends/YahooContact page if not then this fix will not work. If you don't have control over the page I would suggest looking into if Yahoo offers an API so you can control the window and just call their service. There may be a better way to do this. This is just the method that I use.
In the InviteFriends/YahooContact page put this script. Call it from your login button.
<script type="text/javascript">
function Login() {
if('loggedinSuccess' == true) {
window.parent.location = 'Put the redirect URL here';
window.close;
}
}
</script>