# Best practices for shutting down workers

**URL:** https://community.temporal.io/t/best-practices-for-shutting-down-workers/1283
**Category:** Community Support
**Tags:** java-sdk
**Created:** [January 8, 2021, 6:08pm UTC](https://community.temporal.io/t/best-practices-for-shutting-down-workers/1283 "2021-01-08T18:08:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Gordon\_Bean](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/gordon_bean/32/224_2.png) [@Gordon\_Bean](https://community.temporal.io/u/Gordon_Bean)
#### Post date: [January 8, 2021, 6:08pm UTC](https://community.temporal.io/t/best-practices-for-shutting-down-workers/1283/1 "2021-01-08T18:08:22Z")

</div>

Is there anything I should do to cleanly shutdown a workflow or activity worker?

---

<div class="post-metadata">

### Author: ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)
#### Post date: [January 8, 2021, 6:44pm UTC](https://community.temporal.io/t/best-practices-for-shutting-down-workers/1283/2 "2021-01-08T18:44:24Z")

</div>

I believe the following should work:

```java
workerFactory.shutdown();
workerFactory.awaitTermination(terminationTimeout, TimeUnit.SECONDS);

```
