# Remove Executor::close\(\) \(\#50970\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/6c9b813f38182a368de6dcecd59e60b162a6ae0c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 6c9b813f38182a368de6dcecd59e60b162a6ae0c

Requested commit: 6c9b813f38182a368de6dcecd59e60b162a6ae0c

Commit: 6c9b813f38182a368de6dcecd59e60b162a6ae0c

Tree: 134a96e245e92b716cbcd1bd737f6484063ccb03

Author: Conrad Irwin

Committer: GitHub

## Message

```
Remove Executor::close() (#50970)

Co-Authored-By: Eric Holk <eric@zed.dev>

In app drop we had been calling `.close()` on the executors. This caused
problems with the BackgroundExecutor on Linux because it raced with
concurrent work: If task A was running and about to poll task B, the
poll to task B would panic with "Task polled after completion". This
didn't really matter (because the app was shutting down anyway) but
inflated our panic metrics on Linux.

It turns out that the call to `.close()` is not needed. It was added to
prevent foreground tasks being scheduled after the app was dropped; but
on all platforms the App run method does not return until after the
ForegroundExecutor is stopped (so no further tasks will run anyway).

The background case is more interesting. In test code it didn't matter
(the background executor is simulated on the main thread so tests can't
leak tasks); in app code it also didn't really make a difference. When
`fn main` returns (which it does immediately after the app is dropped)
all the background threads will be cancelled anyway.

Further confounding debugging, it turns out that the App does not get
dropped on macOS and Windows due to a reference cycle; so this was only
happening on Linux where the app quit callback is dropped instead of
retained after being called. (Fix in #50985)

Release Notes:

- N/A

---------

Co-authored-by: Eric Holk <eric@zed.dev>
```

## Parents

- [c841b48e4f7d951e091ecd1d86fe120905ad9796](https://git.cafe/gitcafe/zed/commit/c841b48e4f7d951e091ecd1d86fe120905ad9796?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/6c9b813f38182a368de6dcecd59e60b162a6ae0c?format=markdown)
