I've been able to maintain friendships and alliances through the end game, too. The only issue I've noticed has been after "fake wars" - ones where I'm DOW'd due to a joint war or I auto-DOW someone due to an alliance, but no actual fighting takes place and we peace out after 10 turns. After a fake war I find I still have positive relationship factors, but the AI won't accept my offers of friendship and I need to wait until they offer friendship to me, which typically doesn't take too long, but still delays resuming the friendship for a few turns. But possibly I'm just not persistent enough in making the friendship requests. I certainly haven't run into the AI turning against me because I'm winning. I kind of wish they would, as it would make the end game more interesting. Possibly the speed at which you go from hitting the "close to victory" mark to actually winning is a factor? I play Standard speed and have only done science and culture victory runs in R&F.