Lets suppose I finished a game. How do I get the game to stop, when it is playerd through and return to windows?
Just call the QuitGame() function, it's in the manual.
For better issues make a room for an ending then make a button and hotspot of whenever mouse click restart the WHOLE application and return to the main menu :).
...restarting with RestartGame() function.
I'd do it like said, make a GUI or a room where the player is presented with the options to Restart and Quit
Another cool thing you can do is if the player gets a perfect score, a minigame opens up or something like that. I don't know how to do that, I only am suggesting it.
Already in the BFAQ: http://bfaq.terran-x.com/#graphics13 and I added that last paragraph to it, too. Perhaps I should move that question to a more appropriate category or re-word the question on the page.
Either way, please check all resources and the AGS manual before asking questions.