How do I remove an iMessage account from OS X (Yosemite) Messages app? I added my iMessage account to my work MacBook and now I want to remove the account, but Messages won't let me.

I Signed Out of the account and deleted the message history, but now when I start messages it still prompts me to login with the account, and if I go to Preferences the account still appears (inactive) in the list and the Remove button (- sign at bottom) is greyed out.

Is there any way to remove the existence of the account completely?
OK, I figured it out but it's not straightforward. I figured it had to be stored in a .plist file somewhere, so I searched all the .plist files in ~/Library/Preferences for ones that contained the Apple ID I used for iMessages. These were the ones:


com.apple.ids.service.com.apple.madrid.plist
com.apple.ids.service.com.apple.private.alloy.sms.plist
ByHost/com.apple.identityservices.idstatuscache.5A488A33-7FF1-56F5-A3F6-CBC792D5C705.plist


When I searched for com.apple.ids.service.com.apple.madrid.plist on the web I found a link to a very useful answer on the Apple forums that also helped out.

So basically, this is what I did:

Delete the .plist files I mentioned above (note, the last one with the UUID in the name is likely to be different for each user):

cd ~/Library/Preferences
rm com.apple.ids.service.com.apple.madrid.plist
rm com.apple.ids.service.com.apple.private.alloy.sms.plist
rm ByHost/com.apple.identityservices.idstatuscache.5A488A33-7FF1-56F5-A3F6-CBC792D5C705.plist


Then I removed all the chat history and archive:

rm ~/Library/Messages/chat.db*
rm -rf ~/Library/Messages/Archive
rm -rf ~/Library/Messages/Attachments


Then I restarted the Mac just in case. Now the account and everything about it that ever existed on this machine is gone :)