After a while it suddenly seems to connect to a new COM port, COM4.
How do you detect that this (impossible) feat has happened? There is no way for the Arduino to change ports on the PC. The PC must be doing something that makes you think that the Arduino has moved.