Dems taking control of the House had nothing to do with Ryan leaving the Speakership - he did not run for re-election and was no longer going to be a member of the House regardless.
Granted, Ryan did not “lose” the Speaker position by election, but he lost it by selection: he CHOSE not to run again with trump as president pushing an agenda he (Ryan) did NOT want in any shape or means.
Ryan also CHOSE to encourage the “retirement” of nearly 40 senior RINO’s in 2018, giving them an excuse/reason to leave positions open rather than staying on a fighting for Trump’s positions, policies, budgets, and platforms.
An effective, dynamic leader would not have abandoned Trump to Pelosi and the NYTimes/WashPo’s publicity in 2018. He WANTED Trump to fail. That does, of course, leave the positionopen for him in 2020 (if Trump is impeached)/2024 (fighting Pence as nominal lead)/2028 (after Pence leaves in failure like Bush I/Dole/W).