Multistep mechanism of DNA replication-coupled G-quadruplex resolution