Most opportune times for Gretzky to have retired:
(a) 1994
(b) 1998
I would have liked to have seen him retire in spring 1998, I guess. I can't remember -- did he have a two-year contract from 1997, or was he year by year? Anyway, 1997-98 saw Wayne play not very well in the first half but then he cranked it up in the second half and was outstanding (just a point behind peak-Jagr, in the second half scoring), so to walk away at that moment would have been better, I think, than hanging around for that final season.
The final season: As someone noted, he was scoring fairly well in the first part of the year. As of December 20th, 1998, he was tied for 5th in scoring with Fleury and Forsberg, but after that there was just wasn't any gas left in the tank.