Close resource to avoid memory leak