python os kill process code example Example 1: python kill script import sys sys.exit() Example 2: how to kill process sudo kill <PID>