Auto-close added

For easy testing, I have added functionality so that the application
will automatically turn off when all the controls has been drawn.