Can't upload new sketch due to the existing sketch

In the Arduino IDE, I selected Tools -> Programmer -> Arduino as ISP, then Burn Bootloader, but it also gets stuck. The existing sketch starts communicating around one second after it gets reset which seems to be before the process completes.