In HarmonyOS application development, terminateSelf() of the UIAbilityContext class is used to terminate the current UIAbility instance.
If you do not want to retain mission snapshots in Recents after terminateSelf() is called, set removeMissionAfterTerminate to true in the module.json5 file.
{
"module": {
// ...
"abilities": [
{
// ...
"removeMissionAfterTerminate": true,
}
],
// ...
}
}