terminate script using kill python code example Example 1: python kill script import sys sys.exit() Example 2: kill python pkill -9 python