Hitler dying in an uncontrolled circumstance (instead of the result of an organized plot) opens a lot of interesting possibilities; if only because no one would be fully ready for it, leading to a lot of uncertainty and competition in the succession scramble.
If we suppose cancer, then a lot depends on the type of cancer and when in 1940 it proves fatal.
I’m not an expert on the history of cancer treatment, but I imagine that the chances of survival, or long-term remission, in 1940 were considerably less than they are today. Still what would happen would depend on the type of cancer. For instance, pancreatic cancer would be relatively quick and debilitating. Something like Leukemia or bone cancer might be more drawn out. Brain cancer could well affect his mind, and who knows where that could go.
Any of them would have some effect on Hitler’s psyche in his declining days, and I don’t think for the better.
Depending on when in 1940 the cancer became apparent (or the consensus of those who were exposed to Hitler on a regular basis reached the conclusion that he was seriously ill, and that he no longer represented the future) it would shake confidence in the regime in military and Party circles. For the military, that could be very important prior to April 1940 (before the victory over France) versus June 1940 when France was done for. If in April 1940, would the military leaders be eager to follow the orders of a dying warlord?
Would a dying Hitler push his Generals to move west even earlier than they did, and how would that play out if the Battle of France occurred in March or April 1940?
The illness could (probably would) affect Hitler’s state of mind and his stamina. The historic Hitler didn’t face defeat very well in 1945, and it would deeply shake his personal messianic view if his doctors were to tell him he was terminally ill before he secured his Thousand Year Reich. On the one hand he might be drawn to stage some sort of Gotterdammerung for all of Germany to represent his own impending death, or become a recluse, undermining confidence in his leadership (or enhancing some mystical quality about it).
On the other hand, Hitler might test a number of potential successors, and then destroy them before his death because – from his subjective perspective – none could meet his expectations of the new Fuehrer (which might be impossible for anyone to meet since the premise in Hitler’s mind could be that no one can really fit into his shoes). Depending on how far that process gets, it could leave a power vacuum at the head of the Nazi Party, or catapult a secondary figure into a commanding position at the time of Hitler’s death (such as Heydrich for example).
If the death comes after the Fall of France, then the successors will have to work to restore confidence in the Nazi regime, which might be seen to falter, or be weakened with the loss of the founding and commanding figure. The French resistance might be more emboldened, and/or Stalin may see an opportunity to press his luck during the turbulence of a succession crisis in the Reich, potentially leading to an earlier German-Soviet border conflict.
In all likelihood, with Hitler’s passing, the leadership would fall into some kind of collective group which would balance out the competing power centers within the Nazi Party and the State, including the military (and through them their conservative political allies), at least until one figure intrigued his way to the top – be it Goering, Himmler, Papen, or ?
Would they then try to negotiate a settlement with the UK?
Press the military plan to take on the Russians or shy away from that?
Come to Italy’s aid in the Balkans or let Mussolini fend for himself?
Or as happens with committees, paralyse themselves with inaction? Or push “bold actions” in a gamble to prove they were worthy successors to Hitler?
These open all sort of doors, depending on where you want to take this TL.