<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEPacketTunnelProvider/stopTunnel(with:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEPacketTunnelProvider(im)stopTunnelWithReason:completionHandler:"
  },
  "title" : "stopTunnel(with:completionHandler:)"
}
-->

# stopTunnel(with:completionHandler:)

Stop the network tunnel.

```
func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping @Sendable () -> Void)
```

## Parameters

`reason`

An `NEProviderStopReason` code indicating why the tunnel is being stopped. Possible codes are listed in [`NEProvider`](/documentation/NetworkExtension/NEProvider).

`completionHandler`

A block that must be executed when the tunnel is fully stopped.

## Discussion

This method is called by the system to stop the network tunnel.

NEPacketTunnelProvider subclasses must override this method.

Do not use this method to stop the tunnel from the Packet Tunnel Provider. Use `cancelTunnelWithError`: instead.

---

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)