exit from python command line code example Example 1: exit python terminal Ctrl+d or exit() Example 2: exit python script import sys sys.exit()