There such things as CONTRACTS breh. Most of these contracts state that Studio A has to have a movie in production every so often for these characters before the rights revert back to Marvel. It happened with Daredevil and Blade, and I think it was CLOSE to happening with FF4 but Fox got Trank and put the reboot into production before the deadline.
X-Men will probably NEVER go back to Marvel, it's a bonfide cash cow.
Spider-Man will probably NEVER completely go back to Marvel. Sony's pure and utter incompetence had them begging for Marvel's help and I'm sure Kevin Feige knew that, Spider-Man being one of their Crown Characters it would behoove them to help pull him out of mediocrity hell.