Even the most passionate engineers are susceptible to this phenomenon. It’s their very passion, in fact, which causes it. Normally, they are motivated by their love for their craft. They take pride in their work. But, when all chance of success is squeezed out, their motivation vanishes right along with it.
Obviously, this is not a desirable scenario. Unfortunately, however, when normally passionate developers are struck by the eye of a storm, some well-meaning managers try to correct their bad attitudes rather than confronting the situation which caused it in the first place. In so doing, they can actually make matters worse. The attitude, you see, is not the problem. The loss of motivation is actually a healthy response which helps developers cope and still be mildly productive, even in otherwise hopeless situations.
The alternative is actually worse. When an engineer lacks this natural coping mechanism, they get overloaded. In trying to accomplish everything, they manage to complete nothing. They become a strangling bottleneck for everyone else. As they are forced to cut larger and larger corners, they are deprived of the joy that they normally derive from a job well done. As they become disgruntled, they lash out in anger, thereby tearing down the morale of those around them.
No—the eye of the storm is not the problem. Having an eye is better than no eye at all. The problem is not the eye. The problem is the storm. If a passionate developer contracts temporary dispassion and giddy non-motivation in the middle of a crisis, don’t make matters worse by throwing fuel on the fire. Take a step back and consider the situation. What was the thing that tipped the scale from challenging to utterly impossible? Learn from your mistake. It’s your job as a manager to ensure that things never get that far out of hand. If they do, it’s not your developers’ fault for handling it poorly; it’s your fault for letting it happen.
Yes, even I will admit that there is some merit to keeping energy high by having optimistic expectations, but you must keep things in balance. If the company's needs ever become hopelessly unrealistic, the best thing that you can do is to shield your developers from them. It does no good to pass the hopelessness further on down the line. Do your best to shoulder the crises. Absorb the worst of the stresses. Insulate your team so that they can stay on task, working in a steady environment, with achievable goals. No, you won't meet all of the deadlines, they are unrealistic after all, but at least you'll meet as many of them as is humanly possible.