Let save_resume_data build torrent list on stopping session

By having the func build the list we can skip torrents that we already have
resume data for (need_save_resume_data is False).
Add flush_disk_cache parameter to save_resume_data

Using this flag avoids potential issue with file timestamps and
is only needed when stopping the session.