Well, these don't really address the problem you posted, but they're things that will likely get mentioned by a SourceMod approver if you submit it as a new plugin:
I'm not sure its a good idea to set cvars using ServerCommand. Use a handle variable, FindConVar (in OnPluginStart), and SetConVarBool instead.
Hook either OnClientDisconnect or OnClientDisconnect_Post, not both. I recommend OnClientDisconnect_Post based on what you're doing.
#define TEAM_UNASSIGNED 0
#define TEAM_SPEC 1
#define TEAM_RED 2
#define TEAM_BLUE 3
Use these from #include <tf2> instead:
TFTeam_Blue // (yes, Blue... not Blu)
You can compare them directly without casting, but you may need to cast them to a cell before using them with GetTeamClientCount (i.e. _:TFTeam_Red)