In the UK, we can put up to £20K into a tax-free ISAs each year and any capital gains are completely tax free.
Emergency cash pot
Many people (and particularly the self-employed) will have an emergency 'cash pot' which they can withdraw cash from should an emergency arise, such as if being unable to work due to accident or health, loss of job, unforeseen expenses, etc.
If you need to withdraw funds (e.g. due to temporary loss of income) it is best to withdraw from your emergency cash pot which typically holds at least 3-6 months of income rather than sell your high-gain stocks/ETFs and be out of the market.
Unless you are retired and are drawing a good pension, you may need an emergency pot that is large enough to support you for at least 6 months or so, especially if you don't have any other 'cash' resources.
This pot should not be invested in volatile assets because it needs to be available at all times - if you invested it in the S&P500 and the stock market went down 50% just when you needed the cash, you would only have half the emergency funds you thought you had!