Merge "Record task snapshot before shutdown." into main