I think he killed her because they were obviously cornered and they would have extracted intel out of her (similar to the mission where Obito 'died' -- they had her captured for intel). So he did the same thing as Kisame and killed his comrade to prevent intel from getting out.
Well I know its code to prevent the enemy from getting intel by any means, but kakashi learned from obito that betraying your friends would make you lower than scum.
Kakashi didn't kill Rin Obito was seeing things due to a genjutsu.
On a side note anyone else bothered with how they changed it from Obito yelling at Kakashi "You LET Rin die" to showing Kakashi kill Rin? Kinda not the same thing right?