Secret Window

Mort Rainey, a writer just emerging from a painful divorce with his ex-wife, is stalked at his remote lake house by a psychotic stranger and would-be scribe who claims Rainey swiped his best story idea. But as Rainey endeavors to prove his innocence, he begins to question his own sanity.
The most important part of a story is the ending.