I've done this sort of 'timeout' routine by sending the program into a tiny loop which monitors only the desired pins, after the main stimulus has been received.

Each time the miniloop executes, a counter is incremented.

If I receive an appropriate response (button, etc), I clear the counter and jump to the appropriate section of my code.

If the counter increments and reaches $BIGNUM, I exit the loop and go back to the main program.

John