for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
import ...., sys #import sys
while ....: #your loop
for event in pygame.event.get(): #user exit programm
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
running = Truewhile running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False