10

The web has many articles (and videos) on starting a new Maui app. Microsoft's Maui documentation does discuss the MauiApp lifecycle and enumerates delegates to trigger the appropriate events for each of the supported platforms. I have been unable to find any concrete example of how to initiate any of these events other than creation. Specifically, how do I initiate a MauiApp shutdown, whether that involves putting the app to sleep or actually removing it from memory, as appropriate for the platform? Maui metadata mentions such procedures as Quit(), StopAsync(), and CloseWindow() but I have been unable to get any of these (at least while debugging) to actually visibly terminate the app.

dodekja
  • 537
  • 11
  • 24
DP10234
  • 101
  • 1
  • 4

2 Answers2

16

For Android apps:

Application.Current.Quit();

I tested it and it works.

It is compatible with other platforms, but I didn't test.

Mahdi Ataollahi
  • 4,544
  • 4
  • 30
  • 38
2

For Windows desktop this works:

Application.Current?.CloseWindow(Application.Current.MainPage.Window);
Rob
  • 21
  • 3