"The only thing that matters is the ending," Johnny Depp's frustrated author says late in Secret Window. More ironic words have seldom been spoken, as the film's Achilles' heel of a third act doubles as its glaring, fatal weakness. After a terrific first hour, writer-director David Koepp flies so far off the rails that his film might someday be spotted soaring in Jupiter's orbit. Based on a Stephen King novella, Secret Window casts Depp as a successful but deeply depressed writer still mourning his split with wife Maria Bello six months after he found her in bed with Timothy Hutton. Subsisting largely on Mountain Dew, Doritos, and cigarettes, Depp is a broken shell who doesn't seem interested in being put back together. While wallowing in self-pity one day, Depp is visited by John Turturro, who claims Depp has plagiarized one of his stories. Alas, it takes more than the sinister appearance of a mysterious stranger to shake Depp out of his lethargy, but it rapidly becomes apparent that Turturro is a genuine threat, and possibly one who's seen Fatal Attraction and Cape Fear a few too many times. Secret Window feels like two movies locked in mortal combat: The first film is a vividly realized character study with a feel for the subtleties of a smart, articulate, alienated writer battling depression and loneliness. The second is a dire, arbitrary thriller topped off by not-so-surprising surprise twists. Depp's terrific performance finds him wielding bone-dry sarcasm like a scalpel, his wisecracks bursting to the surface in passive-aggressive spurts. Secret Window is almost worth seeing for his characteristically assured performance alone, but Koepp sabotages Depp and his surroundings with an ending so atrocious, it callously betrays everything that came before it.