As breakups go, this shouldn't be too messy. You simply resign. Submit a written statement to the board of directors informing them of your resignation and its effective date.
Resigning won't cut off anyone's right to try and sue you for wrongful acts you committed while you were an officer. But in most states, the corporation will indemnify you -- in other words, provide backup such as legal defense and reimbursement for court-ordered money damages -- if you and the corporation get sued for your pre-resignation activities. (There are of course, limits on the wrongful acts that can be indemnified. Officers who are sued for sexual harassment, for example, are usually on their own.)
Check your corporation's articles of incorporation or bylaws to make sure this indemnification exists, and that it extends to you after you've resigned. Also, if your company took out directors and officers ("D & O") insurance, check the policy to make sure you'll be covered if you are later sued personally.
If you're also a shareholder, as a general rule you are not personally liable for the debts and liabilities of the corporation. If you and your corporate comrades have been observing basic corporate formalities, creditors shouldn't be able to come after you personally for the corporation's debts and liabilities. The rare exception would be where a creditor tries to "pierce the corporate veil" because you and your buddies have been, say, commingling corporate funds with personal funds, or committing similar no-nos. In such cases, your personal assets might be at risk.
Now, what are you proposing to do with your shares? If you intend to sell your shares to a third party, check with a lawyer to make sure the buyer won't cause the company to lose its S corporation status. There are legal restrictions on who can own shares of an S corporation. If you plan to sell your shares back to the company instead, be careful: Most states require a corporation to meet certain financial requirements before it can legally redeem or purchase a shareholder's shares. For instance, if the corporation can't pay its debts after it buys you out, the corporation (and its creditors) could come after you for that money.
You should be able to handle the basics of your departure yourself, without the assistance of a lawyer. But if you're ending your relationship with the corporation because of its shaky or questionable business practices, give your lawyer a jingle. You and your lawyer should look closely at the company's debts and liabilities to see whether they could leap out of the past and bite you.