Managed File is stuck with a temporary URI, even after saving it as permanent file
You need to mark file as "used", there is file.usage service for that, you can do it by next code: \Drupal::service('file.usage')-&gt;add($file), but after removing file from config or changing it by another file don't forget to remove file usage by \Drupal::service('file.usage')-&gt;delete($file), otherwise file would not be removed from file system.

In drupal 8.3 default behavior about unused files was changed and by default all unused files should not be deleted, until variable make_unused_managed_files_temporary is true.