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.