---
title: "Shutdown and Draining"
description: "Learn more about the default behavior of our SDK if the application shuts down unexpectedly."
url: https://docs.sentry.io/platforms/rust/guides/tracing/configuration/draining/
---

# Shutdown and Draining | Sentry for tokio-rs/tracing

By default the SDK sends out events over the network on a background thread. This means that some events might be lost if the application shuts down unexpectedly. The SDK provides mechanisms to cope with this.

When the Rust SDK initializes a guard is returned from the `init` function. The destructor will automatically wait `shutdown_timeout` seconds. This means you just need to hold on to the guard and make sure it disposes on shutdown. Alternatively the client can be closed:

```rust
use std::time::Duration;

if let Some(client) = sentry::Hub::current().client() {
    client.close(Some(Duration::from_secs(2)));
}
```

After a call to `close`, the client cannot be used anymore. It's important to only call `close` immediately before shutting down the application.
