Why do you think that was the reason?
PIS accepted around 700 000 immigrants from Africa and Middle East in last 8 years. Tusk didn't. PIS scared people with immigrants and accepted them in thousands behind their backs.
Can someone explain to me if there is any realistic scenario where PiS manage to hold on to power?
The situation in general is very unpredictable, despite known election results. President Duda can veto the new coalition for the next 2 years, stall them with the constitutional court "freezer" and will be stalling the formation of the new rainbow carebear coalition's government. PiS and Morawiecki will get first shot at a "new" cabinet and won't win the vote of confidence, but those procedures take time in which the new coalition might start fighting each other before they vote on their own PM cabinet happens. The leftards especially can easily lead to an early election, and are already screeching demands (and unless this is a negotiation tactic) this means it is likely they are too stupid/detached from reality to be able to hold the line until an allied president wins elections (20 years of election failures by the left show this). PiS is probably banking on early elections or at least a comeback if they get their next president in 2 years (which would show they have hope to rule again).
OTOH PiS in opposition, without minister positions and other incentives to nicely fall into line behind Kaczyński might start fracturing. Ziobro camp is claiming they'll form a separate parliamentary club from PiS (again, this is a deja vu of their 2000s origin story), Szydło camp doesn't like Morawiecki 's people (since Morawiecki replaced Szydło as PM, in addition to ideological/background differences), who knows what Macierewicz has in his head and wants to do (schizophrenia or moscow control chip? you be the judge, though he certainly didn't sue that book author for slander regarding Russian ties...). On top of that PiS has professional leeches who also are rats that jumped sinking political ships in the past to PiS, so they might do it again.
Kaczynski is getting visibly more senile, even a longer hospitalization could be enough to trigger a free for all within PiS, since he simply is getting too old to keep discipline (and he can kick the bucket suddenly), especially now when they're out of spoils to split.