I hope this isn't too complicated... You could have a turnscript when in the room that has a "deadman" sort of variable. Basically, you have a flag somewhere (in the room, on the player) like "validcommand" which is initially set to false. If they enter a good command, it gets set to true. Else it will remain false when the turn script occurs.
The turn script runs after each command. If the "validcommand" flag has not been set to true by a good command, then it knows a good command wasn't entered, and the player gets booted. If there can be multiple good commands in sequence (else the boot), then have the turn script do like this:
if (player.validcommand) {
// player entered a valid command. Set to false for next command.
player.validcommand = false
// Now it will go back and get the next command in the room.
} else {
// Player didn't enter a valid command. Boot them.
msg("Get out!")
player.parent = outsideroom
}
Just set "validcommand" to false when entering the room and enable the turnscript. Disable the turnscript when they leave the room. And set validcommand to true if they do something right.
If at any point, they don't invoke a command that explicitly sets "validcommand", they get booted.
OR
If it's the case that answering the question moves them to the next room, then you might be able to just have the turn script boot them, period. if it's enabled when they come in the room and disabled when they leave, then if they're still in the room when the turn script triggers, they did bad.
(There might be an initial issue with not having the turn script boot them as soon as they come in the room. If you decide to go this way, I can help with that.)