Other Macs are signed in with same Apple ID and password on the same network with the primary Mac from where you are trying to delete the gmail account from Mac system preferences > internet accounts .
Disconnect all Macs by signing out the Apple ID and password from them or finest way is remove all Macs Check your Apple ID device list to see where you're signed in - Apple Support
The primary Mac will be separated and yet signed in with the same Apple ID and password .
Before deleting the account Use your internet accounts on Mac - Apple Support
You must always turn on iCloud Drive and desktops and documents box Use iCloud Drive to store documents on your Mac and iOS devices - Apple Support
And if Apple ID is set up with secondary authentication account in which three answers for respective questions , date of birth , rescue mail address and its password are added , the iCloud Keychain is always set up .
you must have iCloud Keychain security code in your records , if you don’t remember it , change iCloud Keychain security code from old one to new one as this code has to be filled up in the upcoming steps .
( a ) Open system preferences > iCloud > the box for keychain is checked , click on options , click on change security code .
( b ) Click on security code > enter new code in the fields and click on next , you have to enter the new code for the second time and click on next .
In the next window the country code is written , enter your trusted mobile number …….and click on done .
Again enter your Apple ID password to update your account settings and click on ok , hence the code is changed , so write down this code in a safe place .
As in future if you again plan to add the accounts the six digit iCloud Keychain verification code is required and having in records its very easy to add both gmail and iCloud accounts ( if you wish the steps can be described ) .