Allow passing block to code and demo

This will get passed the resulting app so you can do things like wire up
additional closing commands on an app without having to modify it's source
directly.
Will pull in the default quit from your PR on ctrl + w since I've got my own weirdness in my presentation (running it from a Wii remote, so I need it to map to escape...). Ctrl+w seems better for the general case.