Intermittent Arduino Mega2560 problem: "COM5 already in use" - SOLVED

Further to this, it seems that you can avoid the problem altogether. Rather than opening the serial line in setup and leaving it open, open it only when required, write to it, then close it again.