The error did not appear if I applied to the lens flare to a small test file.
It did still appear with a different codec.
I did not try disabling the hardware accelerated encoding yet, since I got an idea that might work, since the new small test file worked.
I replaced the clips in question to an After Effects composition and added the lens flare in After Effects. The render has now gotten past the place where it stopped when the lens flare was the problem.
It doesn't change that I have a problem exporting the file when the lens flare is added to the video in Premiere Pro, but it's a nice workaround that doesn't add up to too much extra time.