properly closing graphs