We all know, that in The Last Name, L survives, by writing his own name in the death note. But why did Rem die then? I mean a shinigami dies when he kills a person, in a way that saves the life of another person. But L didn't die. So technically, Rem shouldn't have died, right?
In that movie, Rem died due to the rule where a shinigami will die if he explicitly tries to extend someone's life by killing another using the death note. This happened because Kira guided L towards Misa as the second Kira. Once L has proven that she is, she will be executed. That's why Rem killed L. And since Rem extended Misa's life by killing L, Rem died (Rule XVII:1).
L didn't die because before Rem did that, L had already written his own name in the death note that they confiscated from the news announcer. By the rules of Death Note, the first one written takes effect while the latter is ignored (Rule XV:1). So since L had already written his own name, when Rem wrote L's name, it did not take effect.
See Death Note Rules.