You can use select() on sys.stdin combined with a timeout. Roughly speaking, your main loop will look like this (untested):
while True:
r,w,e = select.select([sys.stdin], [], [], 600)
if sys.stdin in r: # data available on sys.stdin
if sys.stdin.read() == 'q':
break
# do gmail stuff
To be able to read a single character from stdin you will need to put stdin in unbuffered mode. An alternative is described here. If you want to keep things simple, just require the user to hit enter after the 'q'
The -u flag I mentioned earlier won't work: it may put pyton in unbuffered mode but not your terminal.
Alternatively, ncursus may be of help here. I'm merely hinting, I don't have much experience with this; if I want a fancy user interface, I'd use TkInter.