<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/TorSession/stop()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor0A7SessionP4stopyyYaF"
  },
  "title" : "stop()"
}
-->

# stop()

Stop the Tor instance and release any resources.

```
func stop() async
```

## Discussion

Stopping is best-effort and non-throwing: if Tor is already idle,
stopped, or in `.failed`, this is a no-op. A running production
conformer sends `SIGNAL SHUTDOWN` through its embedded control
client (per control-spec.txt §3.7), waits for `tor_run_main()` to
return, closes the control socket, and optionally removes the data
directory when `configuration.ownsDataDirectory` is true.

> Important: After this call returns, the ``doc://Tor/documentation/Tor/TorSession/events`` stream is
> terminated (no more values are emitted) and ``doc://Tor/documentation/Tor/TorSession/socksEndpoint``
> reverts to `nil`. Calling ``doc://Tor/documentation/Tor/TorSession/start()`` again on the same instance
> is supported and creates a fresh data directory when
> `configuration` specifies an ephemeral path.