Does a Shinigami still die if they extend a human life without knowing it? I've started watching Death Note and I'm a bit confused on an aspect of Shinigami. 

In episode 12:


   Gelus dies because he killed the would-be murderer of Misa Amane. By doing this he extended the life of Misa for which he disappeared into glitter as they aren't allow to extend lives.


If a Shinigami killed a person at random who was planning to murder a person the next day, he would be extending the life of the victim the murderer was planning to kill. Would the Shinigami die in this scenario?
If the god of death is using the death note was killing at random, it would not result in the god of death dying. See rule XVII:


  If the god of death decides to use the Death Note to kill the assassin of an individual he favors, the individual's life will be extended, but the god of death will die.




The killing will only result in the god of death dying if they kill someone who is going to kill an individual the god of death favors.