Fix close issues.

Fix close issues.

The close() method was removed in 882ad049986bbcaf1070f995d1c2f05b842ef3ac.