Whom Gods Destroy

Kirk and Spock investigate an insane asylum where a former Starfleet captain is being held, only to discover that he has freed the inmates and is running the place.