[client] Fix some resource leaks.