exit from python command line code example Example 1: exit python terminal Click to copyCtrl+d or exit() Example 2: exit python script Click to copyimport sys sys.exit()