added try/catch for close()