The movie you're referring to is called 'Misery' (1990). It is an American psychological thriller film directed by Rob Reiner and based on Stephen King's 1987 novel of the same name. The story revolves around an author who is held captive by his number one fan after a car accident.