Cubase 8.5 recording midi hundreds of bars ahead

I have recently had strange activity in Cubase 8.5.2 where randomly midi is recorded but hundreds of bars ahead in the track. I have no idea why it is doing this and it seems to be happening more often recently. The only way to get around this is to close the program down and run it again after saving. Any ideas?