Router malware like VPNFilter (linked to GRU's Sandworm team) loads in stages. The first stage persists across reboots, but later stages — the ones that intercept traffic and execute commands — live only in memory.
Rebooting clears those memory-resident stages, forcing attackers to re-infect your device. But the persistent first stage remains, and the underlying vulnerability that let them in is still open.
The real fix: update firmware (patches the vulnerability), change the admin password (blocks credential-based access), and disable remote management (removes the attack surface). Rebooting is step one — not the final step.