Mega 2560 randomly hanging

The arduino mega boards use a bootloader that has a 'special but never used' feature that if it sees three !!! characters in a row in the data being sent to the board during a upload operation, the bootloader enters a 'monitor' mode waiting for user commands from the PC that will never come. So while it may not be your problem specifically, but it has trapped a lot of other people, so check to see if you have any !!! strings in the sketch code and change them.

Lefty