I would first remove and clean the Idle Air Control. There are threads on the forum on how to do that. It might improve your idle consistency. Then, proceed with a tune up if needed.
What transfer case is in your jeep? I would expect it to be the 249, as most ZJs of 94 vintage with the V8 had a 249. That case has 3 shift positions, 4hi, N, 4lo. If you have some other case, maybe the 242, then you have 2hi, 4w hi part time, 4w hi full time, N, and 4 lo.
Your main problem... when the tcase is in N, then the tranny does not see any significant load. So, shifting through the gears is not loading the engine. When the tcase is in gear, then putting the tranny in gear puts a load on the engine and maybe then you again are running into idle or tune up problems. There also could be issues with the throttle position sensor. Not sure about the grinding noise. That might indicate a tranny problem or a transfer case problem.
Hope this helps.