One thing you can do, is make sure your holiday package is protected by a system such as ATOL (Air Travel Organisers' Licensing) in the UK.
It ensures that you don't lose the money you paid out or become stranded abroad if your travel company collapses. If a protected travel company ceases trading, the scheme protects customers who have booked holidays with the firm.
You can predict if an airline is going bankrupt by points here: Can a passenger predict that an airline is about to go bankrupt? for example:
Yes, there were many, many indicators that Thomas Cook was in financial trouble, from analyst downgrades to their share price and their bond rate.
If the airline is going bankrupt be sure to be protected by travel insurance/the ATOL scheme just in case.
Knowing your rights
This BBC article has a panel outlining the rights of UK customers regarding this:
If you are on a package holiday, you are covered by the Atol scheme.
The scheme will pay for your accommodation abroad, although you may have to move to a different hotel or apartment.
Atol will also pay to have you brought home if the airline is no longer operating.
If you have a holiday booked in the future, you will also be refunded by the scheme.
If you have booked a flight-only deal, you will need to apply to your travel insurance company or credit card and debit card provider to seek a refund.