Actually, when writers sell a book, they sell the rights to a form of publication to the company that buys it. If the writer is smart, he or she will negotiate for the rights to revert after a certain amount of time and will negotiate for other forms of publication to remain open so that the right to do something like a screenplay adaptation isn’t also held by the publisher instead of the author. The publishing company in effect owns the book and only owes the author what their contract specifies.
It’s entirely possible for a company to just sit on the publishing rights and never actually print a book. Some authors have had to file a legal appeal to get the right to publish their own work when a publisher has bought the rights, but never published. The rights for producing a book have also been locked up in limbo for years when publishing companies have merged. That means that the author gets nothing during that time, since nothing is being sold, and even worse, can’t shop it to another publisher.
Screenwriting and book publishing are not really very different things. They both use similar contracts and payment schedules. The actual creator of a work doesn’t have a whole lot of freedom with his or her own creation after the rights have been sold. The up-front costs of making something out of the story are high enough that the risk of failure has to be spread out. Publishing companies or studios have to take the risk that people won’t like the novel or show enough to recoup the costs of producing it. An advance in book publishing is pretty much like the initial payment that studios make to a script writer. The size of the advance payment usually reflects the relative risk of failure. Authors have to take the risk that if it doesn’t make money for the company, it doesn’t make any more money for them (hell, depending on the contract, sometimes they have to pay back part of the advance if the book doesn’t sell enough to cover that). But if it does make boatloads of cash, they deserve a share of that for taking that relatively low payment up-front and for the delay in receiving monies. That’s exactly why residuals exist.
Screenwriters are not employees of the studios any more than book authors are. They are contracted creative talent. They have less freedom than book authors because the studios have, over the years, been able to do things like secure the right to use characters and settings. In part, that’s due to the collaborative nature of screenwriting. The only thing that’s close to that in books is a shared universe like the Star Treck, Star Wars, or Thieves’ World series. That’s why a book author can walk away from a publisher in favor of another unless he’s contractually obligated to write something for them, but a TV show is dead forever if the studio doesn’t give the rights back or agree to sell them to a competitor.
For example, Fox owns the rights for Firefly, which is why Whedon can’t just get another studio to do a series based on the ideas, characters, and world that he created. The same thing isn’t true of books. If he had been writing novels, the only thing that would have stopped him from going to a different publisher would be if he were already under contract for more novels, and that would only delay his leaving until he was done with those.
(Disclaimer, I’m not a published author, but I’ve been interested enough in writing to find out the basic mechanics behind getting stuff published. I’ve probably gotten some details wrong, though I’m pretty sure I’m right in the basic ideas.)