At the beginning of internal.cc's close_image() function actually, so it happens before any internals that are needed are closed or shutdown.