Before it runs out really! To extend a lease, If there is less than 80 years remaining it gets more expensive, and if there is less than 60 years you might have problems getting a mortgage.
If the leasholder and freeholder can't agree on a price to extend the lease it can go to a leasehold valuation tribunal.
Go to the LEASE (Leasehold Advisory Service) website for more help, or give them a call. You might wait in a queue on the phone for a while, but once you get through they are really helpful, and explain everything you need to know.