DO NOT MERGE - Move close function declaration to correct scope