"Science fiction" doesn't mean that the story should solely adhere to the concrete, the scientific. If that were the case, we'd have to also damn Heinlein, Clarke, et al. The question of superior forces and the nature of God has always been a part of science fiction.
I also disagree that the show fell to the "deus ex machina" concept to wrap everything up. Traditionally, a "deus ex machina" resolution was employed in a play when characters on two sides of a conflict could not resolve their differences. Then a god would literally descend from the "heavens" on a machine/cloud and sort everything out with just a few directives. I don't believe that happened here--in BSG, the characters themselves were working out their issues, albeit with guidance from "god" or "angels" or whatever you want to call the superior force working in their lives--and didn't rely on a god stepping in to fix everything at the last minute.
As for the specifics, the creators of the show explained both Kara's knowledge of the code and Cavil's suicide in an interview here (
http://www.nj.com/entertainment/tv/index.ssf/2009/03/battlestar_galactica_ronald_d.html).
Excerpt:
(On why Cavil killed himself)
Moore: Cavil killing himself came from Dean Stockwell, to be honest. As scripted, in that climactic battle in CIC, Tigh was going to grab Cavil and fling him over the edge of the upper level, and he was going to fall to his death. Dean called me himself and said, "I just really think that in that moment, Cavil would realize the jig is up and it's all hopeless and just put a gun in his mouth and shoot himself." And I just said, "Okay."
(On the history of "All Along the Watchtower" in the "Galactica" universe)
Moore: The notion is that the music, the lyrics, the composition is something divine, it's eternal. It's something that lives in the collective unconscious of the show, it's a musical theme that repeats itself. It crops up in unexpected places, and people hear it, or pluck it out of the ether. It's sort of a connection of the divine and the mortal -- music is something that people literally catch out of the air... Here is a song that transcends many different aeons and cultures across the star, and was reinvented by one Mr. Bob Dylan.
Eick: It was a simple way to communicate the idea clearly that this is not the future. This is the story of a culture that gave birth to ours. There was an episode in season one in which Helo and Sharon are running for their lives and they hole up in a diner, and there's a Cylon centurion cornering them, and for the longest time we planned to have an old jukebox in the diner that would play, "Yesterday," or whatever we could afford.
Moore: Probably not "Yesterday."
Eick: Okay, something from The Guess Who. I think we felt it was too soon, and would confuse things. It would be so non-specific that people would just be thrown by it. But we were thinking about it that far back, that music would be a great way to tell the audience about the cyclical theme... All the colloquialisms and slang that you hear, and how people interrelate... we get that from them, not the other way around.Hope that helps. :hi: