class MenuScreen(Screen):

    def exit(self):
        self.manager.app.stop()


class TestApp(App):

    def build(self):
        sm = ScreenManager()
sm.app = self
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(SettingsScreen(name='settings'))
return sm
KeyError stopping App in kivy