defer handle close