1-Expand the slot's "wings" or "lips" a bit with a screwdriver.
2-Get two pieces of cable housing, one with an outer housing, metal spiral liner, inner liner.
3-Cut them so they at least make a good bend, maybe 2" for the FD, 2" for the RD.
4-Put them in place and squeeze the "wings" or "lips" back onto them. Doesn't have to be that tight.
5-Get some Slick50 lube, in the red can with the long thin nozzle.
6-Use a rag, to avoid excess, and the red tube on the Slick50, Squirt a small bit of lube into each end of the housing.
7-Run your cables and adjust your derailleurs.
8-You should not see this problem again.
The bend and the wings being gently squeezed back on, and the tightness of the cable running around the bend will easily hold the housing in place. It will not move. The friction between the outside of the housing and the frame is far greater than a lubed cable going through a lined housing, and the movement of the cable is very minimal. You'll have smoother shifting. If you really want to use cable end caps, fine, but they are unnecessary. They may prevent grit from getting in there, but that's not an issue.