Properly close connections on couch backend (#5493).
Prevent file descriptor leaks on tests.