The key is planning ahead.
If you need grant funding to continue a project (especially if you need funding for salaries) applying to funders at least 9 months to a year before the project is due to close is advisable.
Keep staff and volunteers up to date with plans for applying for funding.
Always have a Plan B! Not many grant funders have a success rate of over 40% and contract opportunities usually only have one winner. This means that your application may not be funded.
Apply to several (relevant) funders rather than just one.
Take control of the project's finances. Could you reduce costs by getting services or goods in kind?
Think about what you would do if the project didn't get funded, for example: