Create close function for Ptr data types to clean up ptr and fd settings