This project shows how to write a script that runs after the user has clicked the Red Stop Sign button. (or the project has run a "stop all" block"). - Green Flag. - Red Stop Sign or press <s> key to stop the project. Note that the project end sequence only starts after you have stopped the project!
See this tutorial about what happens after the "stop all" block or Red Stop Sign button: https://scratch.mit.edu/discuss/post/3680384/ The project end sequence is based on the wonderful end sequence of classic Looney Tunes cartoons by Warner Bros that I watched as a kid. Of course that's Porky the Pig. Notes: This project shows that your code after project stop may be a broadcast to start more scripts. If you click the Red Stop Sign button again while the end sequence is running it stops. You could write your end sequence script(s) to force your project to start again so that it would never stop, but I would never suggest that :)