Detect keyboard Escape and exit accordingly