I recently made a small game and then turned it into an application using pyinstaller. When running, there are two ways to close it. It's fullscreen so clicking the red x button isn't included, but basically I have this
if keys[pygame.K_ESCAPE]:
pygame.quit()
and this
if exit_button.colliderect(cursor_rect) and click==1:
pygame.quit()
When the exit button is clicked, the game shuts down without a problem. The cursor shows the little loading symbol for a brief moment immediately after. However, when escape is pressed, the window closes but a message pops up saying, "Failed to execute script". I am on windows 10, the game was made with pygame on pycharm, and the exe was made with pyinstaller --onefile -w game.py.
Maybe it's a bug in the code, but it works perfectly fine in the IDE and I'm doing nothing different. I can also confirm it's not missing images or media. Thanks.