There is no real ending as such. The final episode is called Turnabout Intruder about an old girlfriend taking over Kirk's body. It's based around Dr Janice lester using a life-energy device to take over the Captain's body. She once had a relationship with Kirk and is filled with hatred because she never got to be a captain. The USS Enterprise was called to help her and Dr Coleman from Camus 11 when they were on their way to beta Aurigae. She claimed everyone else was killed by celebium radiation and was ill herself. As Kirk sits with her, she takes over his body and his hers. Eventually Spock realises there is something wrong but he is charged with mutiny. After a time the device wears off and things return to normal, with Janice Lester leaving with Dr Coleman.
You can find out lots more - and see a 60-second preview - at www.startrek.com