Until recently I spent about 20 years contacting in IT in the UK (City / Central London) and I always budgeted about a month from starting to look for a new contract to my first day on the job, so 5 weeks shouldn’t be a problem for most companies.
I’ve been told that the current contracting market (IT, London, Jan 2026) is much harder than in the past, so you might even appreciate 5 weeks salary while you search…
If you really want to exit earlier, just talk to your current line manager once you’ve been offered a contract and tell them the role isn’t for you and you’re giving your notice of resignation (send a copy to HR for the record), then tell them you want to leave earlier than 5 weeks if they’ll agree to it. Chances are that because you’ve only been there a couple of months they might just let you go as soon as you want - you’re not really a critical part of the machine just yet.