The war ends in Europe in 1945 but the battles in the Pacific continue. The Enterprise is part of an overwhelming Allied force that assaults the Japanese island of Okinawa. There is, by this time, absolutely no hope of a Japanese victory or even any form of peace short of unconditional surrender, a condition too humiliating for the Japanese to accept.
So instead of living off the decreasing dividends of war, they began spending the principal. The Imperial Navy threw everything they had left at the landings of American soldiers and marines at Okinawa, concentrating on the fleet off shore.
The film doesn't mention it but virtually every Japanese soldier on Okinawa died at well-constructed defense lines, and many committed suicide, including the general in charge. The Navy sent the world's largest battleship, the Yamato ("Japanese Spirit"), towards Okinawa with orders to beach herself and serve as a fortress, since there was only enough fuel for a one-way trip. It was sunk by air.
But the most devastating weapon used against the Allied navy was the Kamikaze -- ill-trained Japanese pilots flying airplanes loaded with explosives directly into ships. Three hundred and sixty eight American ships were damaged and another twenty eight sunk. It was the most costly battle of the Pacific war for the Allies and for Japan. The Enterprise was severely damaged by a single kamikaze flown by a skilled pilot, after which it was sent to the states for major repairs just before the war ended.
The episode (and the series) ends with the reflections of some of the surviving Marines, sailors, and aviators of the Enterprise. It's moving. Nothing so terrible should be allowed to become moving.