Your plumbing diagram does not show a spa make up loop for fresh water in the pool mode. My guess is that you are using the return three-way valve for the spa make up water and when you turn your system off then the spa drains down to the pool.

If that is not the case then you may have trash caught in one of the three-way valves or one of the three-way valves may have been damaged by PVC glue when installed.

If your system is automated then maybe one of your actuators needs adjusting to close all the way.

You could also install a check-valve on the pool suction side of the three-way valve and another check-valve on the spa return side of the three-way valve.

Hope this helps