1# 停止PageAbility
2
3
4停止PageAbility通过featureAbility中的terminateSelf接口实现。
5
6
7  **表1** featureAbility接口说明
8
9| 接口名 | 接口描述 |
10| -------- | -------- |
11| terminateSelf() | 停止Ability。 |
12| terminateSelfWithResult(parameter: AbilityResult) | 设置该PageAbility停止时返回给调用者的结果及数据并停止Ability。 |
13
14
15如下示例展示了停止Ability的方法。
16
17```ts
18import featureAbility from '@ohos.ability.featureAbility';
19import hilog from '@ohos.hilog';
20
21const TAG: string = 'PagePageAbilityFirst';
22const domain: number = 0xFF00;
23```
24```ts
25//...
26(async (): Promise<void> => {
27  try {
28    hilog.info(domain, TAG, 'Begin to terminateSelf');
29    await featureAbility.terminateSelf();
30    hilog.info(domain, TAG, 'terminateSelf succeed');
31  } catch (error) {
32    hilog.error(domain, TAG, 'terminateSelf failed with ' + error);
33  }
34})()
35//...
36```
37