Oh, and I realized that for leaving a level, a dialog would make things extra complicated and is not really needed, but a countdown like the one for rerstarting a level would be perfect.
It would be a little complex with the way the game is structured to integrate a dialog. However, that's a great idea to re-use the countdown timer for leaving the puzzle too. :)