As soon as you visualize the geometry of the situation you can easily find a solution. It's all about selecting the right time to leave the Moon.
First, forget about the Moon and imagine a spacecraft in a high circular orbit around the Earth.
In the pic above we have a spacecraft in the black initial orbit and we want to get it into the red transfer orbit.
The most efficient way to do that, is by making a burn in the retrograde direction (red arrow).
Now let's add the Moon and a spacecraft in a polar orbit around it.
Notice how the orbit of the spacecraft around the Moon, keeps the same orientation relative to Earth, as the Moon goes around its orbital path.
The best time to leave the Moon is when the spacecraft's orbit is aligned with the retrograde direction. You get two chances per month (more accurately, per lunar orbit).
The worst time to leave is when the spacecraft's orbit is perpendicular to the retrograde direction. This also happens twice per month.
So, how will you know when the spacecraft is aligned with the retrograde direction?
1st method.
Open OrbitMFD on both sides. On the left set the reference to the Moon and the frame to the Ecliptic. On the right set the reference to Earth, target the Moon and set the frame to the Ecliptic.
Wait (time-warp or edit the time in the scn editor) until the spacecraft's LAN on the left and the Moon's TrL on the right have a difference of 90° or 270° (two chances per month).
Because the Moon is not perfectly aligned with the Ecliptic, but has a relative inclination of ~5°, you might be slightly off the actual retrograde orientation. Worst case scenario is either + or - 5°. Most of the time it's somewhere in between. This will affect your TEI burn by only a few (less than 10) m/s.
2nd method.
Open IMFD and select the Map program. Set the reference to the Moon and press DSP, so you can see the Moon's path around the Earth. Center the Moon and Zoom in. Make sure that the projection is set to Ecliptic.
Wait (time-warp or edit the time in the scn editor) until the spacecraft's orbit is aligned with the Moon's orbital path.
This method is more accurate.
Once your orbit around the Moon is aligned with the retrograde direction you can continue with the standard way you perform your TEI burns. LTMFD should work at this point and give you valid solutions to return to Earth, but I can't be sure since I never use it.
If it doesn't work, TransX and IMFD will give you valid solutions from this point.
If you don't know how to setup the return with either of these two MFDs, post a scenario and I (or someone else) will set up the plan back to Earth with instructions.
Welcome to the forums
