I suspect there are two possible reasons why Honda is closing down its Swindon factory. The first is technological, the UK's program to make it the place for battery design and manufacture is already out of date compared to what either Japanese government or Honda's research have discovered. This ties in with Nissan's decision to not build an electric vehicle in the UK and arch Brexiteer Dyson to move his operations to Singapore. Battery tech is the key to winning the electric car war but Honda is also the world's biggest manufacturer of motorcycles and a step-change in battery design would be even more important to them.
The second reason could be diplomatic. The Japanese government has gone from enthusiastic about a free trade deal with the UK to lukewarm. Given the crassness of the UK's government's Brexiteers it is not beyond the realms of possibility that one of them grievously insulted either a member of the Japanese government or a high ranking executive at Honda Japan. The Japanese would have smiled politely, only to go into a rage once back in their own enclave. What better way to teach the British a lesson than closing down the jewel in their crown that a month ago was described as producing the best quality cars in Honda's network and assured that they would not be affected by Brexit?
It could be a combination of the above, the offer of innovative battery technology and payback for some perceived diplomatic insult. The UK government has a notorious history of wasting tax-payer's money on auto related projects that come to naught and the current mob don't inspire much confidence, do they?