Flashing Atmega328PB only works once

Are you still having this problem? If so, please provide a complete sketch and exact set of steps to reproduce the problem.

I have an ATmega328PB board and was going to see if the problem still occurs when using MiniCore, which also uses the optiboot bootloader but perhaps a different version.