Can I sell my E-2 business and still retain my visa?

Yes, you can, but only if you invest and purchase another business.  Owning a real and operational business that benefits the U.S. economy is the reason behind the E-2 Treaty Investor Visa.  Without the existence of a business, there is no E-2 Visa.  Owning a business is mandatory.

If you already have an E-2 visa and plan to sell your business, consult an immigration attorney and a business expert before selling your business in order to reassure that you do not violate the E-2 visa requirements while in the U.S.  Any unlawful presence in the U.S. will impact your ability to apply for any future visas.