As PP's have noted, there are two ways to approach this. Either leave EP quite early and get to MK before people start waiting for HEA, or leave EP quite late and travel to MK while the HEA crowds are funneling out.
If you want to be in MK before the crowds hit the hub, I would get to MK no later than 8 pm, so would be at the EP monorail station no later than 7:30 pm. As others have said, that would give you a chance to get deep into the park to avoid the HEA crowds and simply use the perimeter paths behind and to the side of the hub and castle to move around MK.
Or, if you want to stay in EP as late as possible, I would be at the loading area of the EP monorail at 9:10 pm. Illuminations is a little less than 15 minutes long, so if you are at the loading area by 9:10 pm, you will beat the crowds. HEA should be over by 9:15 pm, so you will be traveling while the crowds start heading out of MK. You should get to MK a good 20 minutes after HEA ends. If you want the least crowds, go with option 1.