<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Process/terminate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTask(im)terminate"
  },
  "title" : "terminate()"
}
-->

# terminate()

Sends a terminate signal to the receiver and all of its subtasks.

```
func terminate()
```

## Discussion

If the task terminates as a result, which is the default behavior, an [`didTerminateNotification`](/documentation/Foundation/Process/didTerminateNotification) gets sent to the default notification center. This method has no effect if the receiver was already launched and has already finished executing. If the receiver hasn’t been launched yet, this method raises an `NSInvalidArgumentException`.

It’s not always possible to terminate the receiver because it might be ignoring the terminate signal. The [`terminate()`](/documentation/Foundation/Process/terminate()) method sends `SIGTERM`.

## See Also

[`launch()`](/documentation/Foundation/Process/launch())

Launches the task represented by the receiver.

[`launchedProcess(launchPath:arguments:)`](/documentation/Foundation/Process/launchedProcess(launchPath:arguments:))

Creates and launches a task with a specified executable and arguments.

[`terminationStatus`](/documentation/Foundation/Process/terminationStatus)

The exit status the receiver’s executable returns.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)