Well, while not being explained exactly and still left a bit of a mystery, it is not really a plot-hole in the context of the movie, but the whole point of the movie. A major theme of the movie is the difference between man and machine and the question if you can completely supress the human element from the decision making process and to which degree Alex is a human with a huge prostetic or a robot that merely thinks to be a human. And the point that this robotic programming can be overcome by the human soul is a major moral of the story, as depicted multiple times in the movie.
Let's first look at an earlier incident where Alex overcomes his programming. When he isn't able to compete against the pure robots, they override his decision making process by the machine's and only give him the illusion of free will. And when he later gets overwhelmed by emotions at the sight of his own attempted murder, they supress even the rest of his humanity by depriving him of all his emotions, turning him into a real machine. Then his wife confronts him on the streets and tells him about their worries and his son's sorrows. And at this point he starts to investigate his own case and regains his emotions, going against the programming.
Kim: He's supposed to be watching this. Instead he's accessing images of Clara and David arriving at school over and over again. Somehow he's overwriting the system's priorities...
Norton: Give me an image of his brain. He's undoing what we did. His dopamine level is coming back to normal.
Kim: How is that even possible?
Norton: I haven't the thinnest idea.
So there is precedent for the human element -- or Alex's soul if you want the more metaphysical term -- prevailing over the programming, if given the right motivation, even if a scientific explanation how this is even possible is (deliberately) omitted.
Now when first presented with the whole "Red Asset" problem while facing Mattox, it is first and foremost to show that he can't do anything against it and his partner quickly chimes in to save him. But later on the roof, it is much more of a moment of truth. We see that Alex still has considerable difficulties to overcome the programming and only achieves it after quite some time. And another major factor, if not the major factor, is that Sellars actively threatens his family with his gun (and would probably have had to shoot them anyway afterwards for all they saw and heard). So Murphy directly sees his family in imminent danger and the movie has already shown that his family and his feelings for them are the major motivation to overcome his robotic programming.
Sellars: I mean if I wanted to, I could just aim at your little family (points the gun at the family) and I could just kill them, too. And really there's nothing you could do about it because let's face it, you're a robot. You understand that?
And that is the whole point. He is not a robot. You can't just program Alex Murphy away. But there is no other actual scientific explanation for why he can overcome the programming, it is his soul, his humanity and his love for his family that makes the human prevail over the robot. But I wouldn't say it is "just due to his family being endangered?" because that is really the major motivation as presented in the movie.