Fixed a handle leak.

(cherry picked from commit fed569b88348d8b042b9d00371931c9f206e6023)