A colleague recently quit in a way which I believe is exemplary in regard to what you are seeking to do. Steps/considerations:
Give reasonable advance notice. In his case 3 weeks, which is 1 week above the typically required 2 week notice. An extra week may not seem like much, but a manager can use all the advance notice they can get, to help them plan/strategize on how to best handle the resource shortage.
If you are a key player or lead on any projects, bring those projects to a good stopping point, if completion is too far off in the future (or it's a kind of project that is never really 'done').
A good milestone might be major code release to production, or completing any other major task by the deadline. Once the task is completed, typically there is some 'lull' afterwards, which involves tasks of secondary (but not critical) importance -- example could be handling some minor Q&A or non-critical maintenance requests, catching up on documentation, etc.
Transition/knowledge transfer: Make sure you do your best to create a well documented paper trail of your activities, using whatever tools do the job best: usually a combination of Word docs, Excel spreadsheets, well documented program code and logs, intermediate and final output from some processing workflow, etc.
Once the manager determines who will take over your work after your departure, setup a series of transition meetings with this individual(s).
Use the meetings to review and discuss the transition documentation you prepared, answer questions, explain various steps or project plan phases, show location of files on the shared drive, highlight critical to-do's or deliverables in the immediate future as things to keep an eye on (1-3 months). Make sure all this is appropriately documented (not just spoken but actually written down).
The manager might wish to meet with you individually to discuss to whom to transition your work, what the next major tasks would be for this person(s), etc. Think about all these issues ahead of time so you are prepared to provide feedback on these points during the meeting.
Think in advance of a good 'cover story' about why you are leaving. This does not have to have anything to do with your real/honest reasons for leaving, but it does have to sound convincing enough to allow everyone to pretend like it is a plausible reason which does not single out any individual or paint anyone (or any group) in a negative light, i.e. essentially allows everyone to save face while letting you go.
This makes departure easier for everyone involved. Make sure to stick to your story and not to reveal the 'actual reason' during a happy hour etc. Keep things impersonal, consistent, and to the point.
- If you are on really good terms with the manager and anticipate no retaliation of any kind for your decision to leave, you may consider ASKING the manager the question you ask here, and let them suggest the strategy.
Make sure that once you reveal your intention to leave, that you remain firm to follow through, and do not appear to waiver at any point in time. This is easier when you have already accepted another offer, or (if you are leaving the workforce at large) have a bulletproof reason for it (e.g. pregnancy, taking care of relative, spending more time with family, going back to school, etc).
Finally, leave a good impression, not just with the manager but with your colleagues, partners, stakeholders, clients, and any other leadership. Make sure that those staying behind do not feel like they are getting the short end of the stick. Do your best to leave on a high note with anyone and everyone with whom you have interfaced on work-related issues, and say only good things about those who are taking over for you. Lay a good foundation for the work to be carried on. This effort may not be as obvious to the manager, but it will be appreciated by your team, and will come back to you through positive indirect feedback post-departure. On related note, try to keep any drama to the absolute minimum. No picking confidants among the team members to tell them 'the real scoop'; no criticizing others behind their backs; no over-blowing of whatever potential work-related issues may have contributed to your decision (unless it really had nothing to do with work but more with personal circumstances). No drama. Keep it professional.
I am sure others can add some other good pointers, but this should help put you on right track. Good luck!