The title and the body of the question don't match. Selling a site and "holding questions for ransom" are different. They could sell the site tomorrow and you would probably never know (they wouldn't stop the sites and put a "for sale" on the pages).
But, for the answer, lets read the "terms of service" you agreed to...
10. General Provisions
d. Modifications
Stack Overflow reserves the right, in its sole discretion, to modify or replace these Public Network Terms, as our business evolves over time and to better provide Services and Products to the Stack Overflow community, or to change, suspend, or discontinue the public Network and/or any Services or Products at any time by posting a notice on the public Network or by sending you notice via e-mail or by another appropriate means of electronic communication.
So they would be well within the terms to discontinue the service and post a notification on the public network that they have discontinued the service.
Whether it is legal for them to sell your contributions to another entity is another question. User contributions are licensed under CC BY-SA 3.0 which just requires attribution, and does not mean that they can't sell your contributions.
The terms of service has this to say about it:
Subscriber Content
You agree that any and all content, including without limitation any and all text, graphics, logos, tools, photographs, images, illustrations, software or source code, audio and video, animations, and product feedback (collectively, "Content") that you provide to the public Network (collectively, "Subscriber Content"), is perpetually and irrevocably licensed to Stack Overflow on a worldwide, royalty-free, non-exclusive basis pursuant to Creative Commons licensing terms (CC-BY-SA), and you grant Stack Overflow the perpetual and irrevocable right and license to access, use, process, copy, distribute, export, display and to commercially exploit such Subscriber Content, even if such Subscriber Content has been contributed and subsequently removed by you as reasonably necessary to, for example (without limitation):
I don't know if SO has a way to remove all of your contributions, but it does have a way to remove your user accounts, which removes your votes but all of your content will become anonymous.