Arduino Mega 2560 Won't Disconnects from USB port

Hello,

I'm trying to run a program that requires my Arduino to be constantly connected to the serial port on my computer, but whenever I run it the program will work for a couple of seconds to a minute, and then stop. When it stops working I get this error:

the selected serial port avrdude: stk500_send(): failed to send command to serial port
 does not exist or your board is not connected

and then I have to reselect the Arduino's port the tools section.

Is there any way to keep my Arduino Mega 2560 continuously connected to my computer's USB port?

Thanks.

Yes there is but just in case it is your sketch you should add that please.
Dont forget to use code tags ( </> )

You also need to mention more about your project.