cli: add cleanup() method to Application, which runs after main() and all subapplications have executed