Move the close function declaration to the correct scope.