Fixed bug in close()