One more thought. (This is how I brainstorm….just come up with all sorts of options, and later decide which is most feasible, best option, etc. maybe none, but each new idea gets other ideas flowing)
Cut the “return” of the rail wrap around off at the correct spot. Form a roll of the same diameter of the rail (only wide enough for a plug weld) step it the appropriate thickness to be flush with the rail. Insert, plug weld on the rail and the box top. Fill with sand able seam sealer, finish bodywork, prime & paint for a seamless joint on both areas.