Yes. As long as you are still within the UK, you can purchase a policy at any time before leaving. As soon as you receive your Policy Certificate, you are protected under your travel insurance. Be aware that any potential claims you were aware of before purchase would not be covered.
During the quote process, sometimes it becomes necessary to contact the underwriting team for advice or referral. We cannot guarantee that their response would arrive within 24 hours, so on this basis we may not be able to provide cover if you are leaving before then.