Ok here goes my nerdiness.....
The episode was called the doomsday machine. William Windom played Commodore Decker. He knocked it out of the park! His ship was the USS Constellation. They used the wrecked constellation to destroy the planet killer, right after Decker committed suicide in a shuttlecraft by ramming down the gullet of the machine.
I watched it primetime back in the 60's. Left a lasting impression on me of what the future could be. It was a great show!
Ok, now you can laugh😃🤣😆