The bottom of the rebate is level with the bottom of the moulding. The mitre therefore forms a neat corner with the edge of both elements. So cut the moulding first, then make a rebate on the other side to the same depth, then do the mitres and the joints.
Hopefully this end-on photo will help.