Ok, moved the code to line 1 and this causes the quickcart in the header to disappear on page load after redirect from worldpay.
Logging in again returns the quickcart empty.
The system is set up so that the quickcart is only displayed for UK users, who then use the worldpay checkout. Non UK users are not shown an "add to cart" in the header or anywhere else and are instructed to phone in their orders. This system is working perfectly so far.
Ideally would like the return to the success page from worldpay (UK users only) to display the quickcart empty on page load. Is this possible?
Modified success page attached.