You can create a foreground service to prevent applications closed. Foreground Services - Xamarin | Microsoft Learn
Please note: Foreground services | Android Developers
Apps that target Android 9 (API level 28) or higher and use foreground services must request the
Android 12 (API level 31) or higher can't start foreground services while running in the background, you need to start the foreground service in the foreground.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.