Replace app.exec() to app.quit().
Fix a bug in test application.