As an investor in a limited company, you should not have any liabilities (assuming your shares are paid up) once your shares are sold. However, as part of the sale documentation you will often be required to assume specific pre-completion liabilities, particularly in relation to tax, and give promises (warranties) about the assets, the liabilities and the history of the company.
If you continue to be a director, you will retain your responsibilities as a director. If you retire as a director, you will have no responsibility or liability for what is done after you retire. However, you may continue to be responsible for the consequences of decisions made while you were a director. For example, if a company of which you were a director goes into liquidation, you could be held liable for the debts of that company if you had allowed it to continue trading while insolvent.
You may also have other liabilities which you agreed. For example, you might have personally guaranteed the company's bank borrowings, or leased premises. As part of your sale and/or retirement plan, you should look into the possibility of avoiding these liabilities (for example, by getting the continuing directors or shareholders to take over the guarantees).
The position in a partnership is more complicated. You need to make appropriate notification of retirement to avoid future liability. You should take advice to ensure that you will no longer have any partnership liabilities.