In TNG: Elementary, Dear Data, Dr. Pulaski is held hostage on the holodeck by Moriarty.
Why don't they just beam her off the holodeck?
A similar situation occurs in TNG: The Big Goodbye when Picard and some underlings get trapped inside a Dixon Hill holonovel. Wesley explains that mucking around with the holodeck is potentially fatal when the system is on the blink. The system could "abort" and the people inside might disappear entirely. It's not made clear quite why this would happen, but we do know that the computer routinely disposes of any replicated material that's inside the holodeck when it's turned off. It's possible that the 'holodeck safeties' are specifically intended to prevent people from (metaphorically) getting taken out with the trash but that when they're malfunctioning the computer might read the people on the holodeck as merely blobs of matter waiting to be recycled into feedstock.
RIKER: Forget the explanation! Can you repair it?
WESLEY: I don't know if I should. If this isn't done correctly, the program could abort and everyone inside could vanish.
RIKER'S COM VOICE: Do you need more time to study it?
WESLEY: No, sir. Whether we do it now or later, the risk will be the same.
Since Moriarty has done (unspecified) things to the computer, it's possible that a failed transport attempt would present a similar risk to Pulaski.
Moriarty would have had to set up a means to block the transporter. No such indication was made on the bridge. How often have we heard in episodes, "Transporters are offline"? Or, something to the effect of, "We cannot beam her off the holodeck". Face it, this was a mistake in the plot - dialog to not have someone, at sometime, exclaim, "Moriarty has set up a transporter scrambler, and if we try to beam anyone in or out their molecules will..." or "He has control of the holodeck matrix so..." etc.
Just because someone has control of the computer system does not mean they took every aspect of command and control over. Moriarty had the goal of getting the attention of Captain Picard, which he did. Let's not even go into simply locking onto just any lifeform, or getting a skeletal lock on someone (done in Voyager), and I am sure Data could have come up with another means to beam any lifeform off the holodeck. The writers just missed the one needed line to justify the crew's inability to just beam Dr. Polaski off the holodeck. Because backgrounds were fading in and out did not mean transporters would be ineffective - they did not say so in this episode. You cannot relate a previous episode's transporter issues to the new malfunction (accidental creation of a consciousness) to the same malfunction.
If that is not a mistake... then why couldn't they beam the chair off the holodeck in "Ship in a Bottle"? If they can walk off the holodeck with an inanimate object like the piece of paper, the chair should have been able to be removed. Why did the book disappear that Picard threw through the exit? You can't have it both ways. Either inanimate objects of paper, books, chairs, etc. can be removed from the holodeck, or they can't. If, as is suggested, replicated material can be removed, then the book and chair should also have been able to go through the exit.