The end cap is supposed to go over it to keep it in place.. over time the rubber has shrunk a bit.
1) remove end cap
2) reseat the rubber in the groove
3) starting at the end using the flat of the hand manipulate the rubber along a bit, slowly working away from the loose end.
You will have to do it several times to ;creep; the rubber back to where it is supposed to be ( well in to the end cap )
It takes time and patience ( and a sore palm ! ) but it will get there , millimetre by millimetre.
When it is back in place use a little sikoflex or similar ( puraflex 40 is excellent and a 1/4 the price of Sikoflex, available from Tool Station ) inside the cap to hold the rubber and stop it from going back along the rail