Josh Brookes produced a masterclass at Brands Hatch to seal the race win ahead of the British Superbikes finale.