This is definitely a serious issue, but the situation can be controlled to avoid any imminent tragedy, only if capable hands are available to salvage the situation. When a pilot dies, what usually happens is that the second pilot that is attached to the flight will declare an emergency and takes over the operation. During this period, the second pilot also needs someone on his side so that some other little things can be easily sorted out.
The thing is flight attendants have been equally trained to savage the situation in their own way. Mostly, a flight attendant would announce if there is any pilot on board. And if the flight is fortunate to have one, then the invited pilot acts as an assistant to the other pilot who has already taken over the operation. However, in a situation where the hunt does not yield any result, then a flight attendant with a level of knowledge on how to fly a plane can take over as the second pilot.
On a commercial flight, there is always at least one other co-pilot in the cockpit. If the pilot were to die, or be incapacitated in any way, the co-pilot would take over the flight.
There are smaller planes and private planes with only one pilot however. If the pilot were to die on a flight without a co-pilot, it would be up to the passengers to try to land the plane successfully. They may be able to do this by communicating with ground control. There would be no other way for anyone on the ground to help land the plane successfully.