Right now, Nibali leads the Tour De France with his teammate 2 seconds behind. If, on the final day of the tour, they both have the same time, will the team tell Nibalis teammate to let him win, or do they tell them to just race together until the end and then both go for it?
Usually, there are designated team leaders, and the team's priority is to get them the win. Due to the different disciplines in major road racing, it's unlikely that two riders from the same team will be so close, as teams are selected based on the riders' ability to support their leader (or designated person in some aspect e.g. sprinting) and deliver them the victory.
To answer your question, in that scenario I would say that team orders would come into play and Nibali would win.
Also, there is a tradition (not a rule) that there are no attacks on the yellow jersey on the last day, if it's a road stage.
Adding to what TrueDub answered, there have been precedents before where a teammate of the designated team leader has been well up in time to the leader. That can all change in later stages, especially as said teammate may be required to work for the team leader. That being said, if a team finds that the later stages are here and they are better served working for this new 'leader' it has in the past occurred that they rally around this new leader. Rare, but it does happen.