Upvote:3
A few days is more than enough. Actually leaving and re-entering the country at the same day would theoretically also work. You only need to get the stamp leaving the country and a new one with a new date entering the country.
The 4 months you will be staying outside of Morocco is absolutely sufficient to renew your right to a new 90 day free period..