Unless you can claim to know how the Enterprise is wired and what its firmware is like, I'd say you can't rule out that the M-5 can't somehow actively rewire the ship the way today's virus software seems to be able to commandeer people's computers despite their security protocols.
Thematically, the story built-up conflict in which it could be plausible for Kirk to go nuts. The prior relationship with Wesley was only meant to give Kirk inner-doubts. Why was Wesley so approving of the M-5 when Kirk was skeptical? Kirk wonders about this out loud to McCoy. Kirk and Wesley had to come from a common background and yet they diverged over their concept of progress.
What it would have amounted to is a "going postal" situation from someone who feels they're about to lose their career, which to many people is their whole reason to exist. These things happen more often than we'd like to admit. It's easy to shrug it off because we view Kirk as a superhero icon, but within TOS, he was a rank-and-file captain and not the comic book hero he would later become.