His plan was really good, he just went to Konoha to remember Danzo and the village he is still around after the Third died to prevent any action against Sasuke, and at the same time making Kisame think they were under Akatsuki orders to capture the Kyubi, nonetheless Kakashi was unwise or careless enough to mention their organization's name and plans in front of Kisame, therefore making Itachi to make that command, or Kisame would get suspicious and tell Akatsuki that Itachi's allegiance isnt that reliable to the organization. I really think Itachi thought(with sadness or resignation) after Kakashi's words that he messed up and should become a sacrifice to protect his cover otherwise all his plan could of went down the drain. I dont know if he actually with his perceptive skills knew Gai was coming, but he surely took that opportunity to tell a excuse to leave, he never really wanted to "kill" anyone despite having the upper hand with autority. Itachi is a complex mysterious guy but remember he doesnt have that battle thirst nor murder intentions(ironic is that he murdered his whole clan, but everyone knows he got in the corner). Gai appearing was the best thing that could happen to Itachi, i mean Gai really thought that without looking to his eyes he is ok lol, not knowing Itachi has Amaterasu and could cast genjutsu with his finger.