I'm using a script that checks if the wine process is properly launched. If not, stop the wine process and relaunch it till the program properly boots.

My problem is when I quit the program after using it, My python script is still running in the terminal, and doesn't exit.

Can somebody help me to properly exit the script when I close photoshop.exe?

```
#!/usr/bin/env python3

import subprocess, re

keywords = re.compile('^.*Assertion.*$')

while True:
    process = subprocess.Popen(["wine64", "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe"], stderr=subprocess.PIPE)
    while True:
        if process.poll():
            break
        line = process.stderr.readline()
        if line == '' and process.poll() is not None:
            break
        if line:
            print(line.strip())
            if keywords.match(str(line)):
                print("Error keyword match, killing process")
                process.kill()
                break
    print("Process return code %d"%process.wait())

```