improvement of Application::end() handling.