Haven't seen the scene in question, but the keeper doesn't establish a final line.
The rule in question just says:
"A player is in an offside position if: any part of the head, body or feet is in the opponents' half (excluding the halfway line) and. any part of the head, body or feet is nearer to the opponents' goal line than both the ball and the second-last opponent."
Usually the Keeper is the last opponent, but if he comes out and behind him is one of his teammates, that player becomes the last opponent.
With that said, TV ruined the offsides rule, because what once was just a general rule for the refs to enforce as best as they could turned into something overanalysed to death with lines drawn that can tell you if someone was offsides by a hair.