---
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/dotnet/guides/extensions-logging/configuration/draining/
---

# Shutdown and Draining | Sentry for Microsoft.Extensions.Logging

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.

The .NET SDK gracefully handles shutdown, waiting up to `ShutdownTimeout` seconds to flush captured events.

This happens in a variety of different situations:

* Automatically, in the case of a normal application exit.
* Automatically, in the case of an unhandled exception.
* Automatically, for integrations that use dependency injection (`UseSentry`, `AddSentry`, etc.).
* Manually, if you dispose of the result of `SentrySdk.Init` (which is optional).
* Manually, if you call `SentrySdk.Flush` or `SentrySdk.FlushAsync`.

In most cases, you can rely on the automatic approaches and don't need to worry about this.
