Is there a way to disable this function?? This occurs on the MEGA board
That is a result of the bootloader program on the mega becoming active upon a reset. When the bootloader detects that there is not a new sketch upload being attempted it 'times out' and then jumps to any sketch that was previously uploaded to the chip. All arduino boards that use a bootloader use pin 13 as a signaling device. So if your application cannot have that behaviour you will have to erase the bootloader and load the sketch via ISP with a hardware programmer.
Lefty