Fixed a bug in close().