The auto shutoff valve has two inlets and two outlets. One side has the unfiltered water running through it. The line running from the membrane to the reservoir runs through the shutoff valve on the other side. As the reservoir fills and the pressure rises, a membrane in the shutoff is pushed which closes off flow on the unfiltered side.
If your keg is sealed, the shutoff should work fine. If it's an unsealed vessel, you'd need something like a float valve to stop the clean water flow, and by extension build enough pressure in the shutoff to stop flow on the unfiltered side.
See the below image. The top side is the unfiltered side which is regulated by the pressure on the bottom side of the valve