Moved close call to finally block