With my front rack I use a removable section of cable with bullet plugs at either end. Take it out, reconnect and cable is now a rack length shorter.
For rear I have similar points to break it near the fork crown, but that was mostly due to internal routing meaning I had to use thin wires inside and needed to join them where they emerge.
So you could make a break/join point nice and neat for no rack and add the cable back in when required.
That's my dream scenario but I was trying to think of something more immediate.
Tbh I have just removed the basket from the rack and I might just leave it at that. Baskets aren't for me but actually the rack is still useful.
With my front rack I use a removable section of cable with bullet plugs at either end. Take it out, reconnect and cable is now a rack length shorter.
For rear I have similar points to break it near the fork crown, but that was mostly due to internal routing meaning I had to use thin wires inside and needed to join them where they emerge.
So you could make a break/join point nice and neat for no rack and add the cable back in when required.