This is certainly possible, but it’s almost certainly going to frustrate you The key here is to note that, whenever you type something like that, Python will show you the representation of the thing you looked at. So we make that representation exit the interpreter.
class InstaQuit:
def __repr__(self):
raise SystemExit
q = InstaQuit()
But now, any time ANYTHING looks at that - such as globals() - you’ll quit out. A more sophisticated solution would be to change sys.displayhook to special-case your quitter object. but that’s a bit more effort.