In October 1962, U-2 aerial surveillance photos reveal that the Soviet Union is in the process of placing intermediate-range ballistic missiles carrying nuclear weapons in Cuba. President John F. Kennedy (Bruce Greenwood) and his advisers must come up with a plan of action to prevent their activation. Kennedy is determined to show that the United States will not allow a missile threat. The Joint Chiefs of Staff advise immediate U.S. military strikes against the missile sites followed by an invasion of Cuba. However, Kennedy is reluctant to attack and invade because it would very likely cause the Soviets to invade Berlin, which could lead to an all-out war. Citing The Guns of August, Kennedy sees an analogy to the events that started World War I, where the tactics of both sides' commanders had not evolved since the previous war and were obsolete, only this time nuclear weapons are involved. War appears to be almost inevitable.
The Kennedy administration tries to find a solution that will remove the missiles but avoid an act of war. They settle on a step less than a blockade, which is formally regarded as an act of war. They settle on what they publicly describe as a quarantine. They announce that the U.S. naval forces will stop all ships entering Cuban waters and inspect them to verify they are not carrying weapons destined for Cuba. The Soviet Union sends mixed messages in response. Off the shores of Cuba, the Soviet ships turn back from the quarantine lines. Secretary of State Dean Rusk (Henry Strozier) says, "We're eyeball to eyeball and I think the other fellow just blinked." The administration continues to order spy plane pictures, but one of Kennedy's advisers, Kenny O'Donnell (Kevin Costner), calls the pilots to ensure the pilots do not report that they were shot at or fired upon, because if they were, the country would be forced to retaliate under the rules of engagement.
John A. Scali, a reporter with ABC News, is contacted by Soviet "emissary" Aleksandr Fomin (Boris Lee Krutonog), and through this back-channel communication method the Soviets offer to remove the missiles in exchange for public assurances from the U.S. that it will never invade Cuba. A long message in the same tone as the informal communication from Fomin, apparently written personally by Soviet Premier Nikita Khrushchev, is received. This is followed by a second, more hard line cable in which the Soviets offer a deal involving U.S removal of its Jupiter missiles from Turkey. The Kennedy administration interprets the second as a response from the Politburo, and in a risky act, decides to ignore it and respond to the first message, assumed to be from Khrushchev. There are several mis-steps during the crisis: the defense readiness level of Strategic Air Command (SAC) is raised to DEFCON 2 (one step shy of maximum readiness for imminent war), without informing the President; a nuclear weapon test proceeds (Bluegill Triple Prime) and a routine test launch of a U.S. offensive missile is also carried out without the President's knowledge.
In a bid for time while under intense pressure from the military for an immediate strike, President Kennedy authorizes attacks on the missile sites and an invasion of Cuba, to commence the following Monday. An Air Force U-2 reconnaissance plane is sent over Cuba to gather intelligence for the attack, but is shot down, killing the pilot. After much deliberation with the Executive Committee of the National Security Council, Kennedy makes a final attempt to avoid a war by sending his brother, Robert F. Kennedy (Steven Culp), to meet with Soviet ambassador Anatoly Dobrynin on Friday night. Bobby reiterates the demand that the Soviets remove their missiles from Cuba, and in return promises not to invade or assist in the invasion of Cuba. Dobrynin insists that the U.S. must also remove all Jupiter missiles from Turkey, on the border of the Soviet Union. Bobby says that a quid pro quo is not possible, but in exchange for Khrushchev removing all the missiles from Cuba, there will be a secret understanding that the U.S. will remove all of its "obsolete" missiles from Turkey within six months as part of a pre-scheduled plan. The Soviets announce on Sunday that they will remove their missiles from Cuba, averting a war that could have escalated to the use of nuclear weapons. The film ends with President Kennedy dictating a letter of condolence to the family of the reconnaissance pilot, Rudolf Anderson, who was shot down over Cuba as part of the preparations for the invasion, and the Kennedy brothers and O'Donnell outside of the Oval Office as actual audio of President Kennedy's commencement speech at American University played in the background.

Question: What is Kennedy doing at the end of the story?
Answer: Dictating a letter
Alternative answer: Writing a letter to the family of a man shot down over Cuba.