[api] avoid leaking connections in threads

I assume this is a bug in clockwork, but it's easy to work around