added error handling for close