I'm thinking of some kind of energy or will power variable. Something that you can boost by doing certain activities prior to the escape scene and a higher energy score makes it easier to escape.
But in a text adventure format it may be more appropriate to have the player figure out a complicated (but ultimately useless in terms of actual security) lock or series of locks in a limited number if moves, or commands. Perhaps you could even combine the two and a higher energy score gives you a few more command attempts