I don't think I've ever heard a physiological explanation for moonlight or the Moon itself doing anything, but in all stories I can remember, it is the moonlight itself that causes the transformation, so keeping them inside ought to keep them safe. Including Harry Potter:
A cloud shifted. There were suddenly dim shadows on the ground. Their party was bathed in moonlight.
Snape collided with Lupin, Pettigrew, and Ron, who had stopped abruptly. Black froze. He flung out one arm to make Harry and Hermione stop.
Harry could see Lupin's silhouette. He had gone rigid. Then his limbs began to shake.
"Oh, my --" Hermione gasped. "He didn't take his potion tonight! He's not safe!"
Although that brings up the question of why Lupin had to go to the shrieking shack/curl up under his desk instead of hanging out in the dungeons...