Extracted demo-specific functionality in a demo namespace.
Fixed window that was not closing after calling reset.