This should be done with `@onExit`. It's leaking in error cases right now.