I recently upgraded my macbook to Mojave. While browsing some settings in my system preferences, I noticed that my icloud account was linked to my old Apple ID which was linked to my ancient Yahoo account (yes, don't judge). I tried to sign out of that account and that's where the trouble started. It won't let me sign out of icloud without disabling "find my mac" service. I was getting the error: "Your iCloud account couldn't be removed at this time. Turn off all iCloud services and try again."  In order to disable that service, I needed to log into the account, i.e. provide password for my old Apple ID.

I did not remember the password for that Apple ID. I also had closed my Yahoo email associated with that Apple ID. Yahoo lets you restore your account within 30 days of deleting, but I have been pretending that I never had a Yahoo account for a long time now. On top of that, I also forgot the answers to the security questions for that account.

I was able to retrieve the password from the keychain but by then the damage was done. I had locked myself out of the account. The only option was to unlock through a reset email to my closed Yahoo account. Yes, that wasn't going to work. The other option was to wait 8 hours and try the security questions again. That definitely wasn't going to work! I called the Apple customer care. They said they can verify my account if I have the credit card number associated with it. I didn't have that either. Who keeps the expired credit cards around? Not me! No, I did not have the MFA setup on that account as well. Side note, this was my first time calling a customer support center in probably years!

Now that all my clumsiness is out in public. This is how I solved it:

  1. Open /Users/<username>/Library/preferences/MobileMeAccounts.plist and update the enabled flag to false for the service(s) that is blocking you from signing out of your old Apple account. In my case, it was "find my mac" service. Deleting this file and restarting your macbook won't help. That's what Apple customer service will tell you, but the file simply gets recreated on reboot and the problem remains.
{	Enabled = :false;
				Name = "FIND_MY_MAC";
				ServiceID = "com.apple.Dataclass.DeviceLocator";
				......... },

2. Reboot your macbook after this change.

3. You can now sign out of that old Apple ID and go back to pretending that you never had a Yahoo account.

4. Bonus Note: You may want to remove the old account from other Apple services like facetime, calendar, itunes, appstore etc.

5. Bonus Bonus Note: You will need to delete the apps, such as xcode, that are linked with your old apple ID before you can update/install them via App Store with a different ID.

I should acknowledge that Apple customer service advisors were quite helpful. They couldn't help me with the issue completely, but they definitely guided me and tried their best.