It would seem there would have to be some sort of ejection hatch in the vicinity of the matter/antimatter reaction chamber.
In "That Which Survives,"
after Scotty is helped into the service crawlway which leads to the matter/antimatter reaction chamber, he tells Spock over the communicator, "I've sealed off the aft end of the crawl way, and I've positioned explosive separator charges to blast me clear if I rupture the magnetic bottle."
Scotty also explains, "If the magnetic flow jumps, you must jettison me."
Well, if Scotty was ejected from the ship, his red-shirted, Scottish body would have to exit through some opening to the cold vacuum of outer space.
Where would that ejection hatch be? It all depends on where you believe main engineering and the matter/antimatter reaction chamber is located. Everyone has their own opinion on this one.