If coinbase decided to close my account for gambling or some other reason, will I be able to withdraw my funds before they close my account?
I don't know about coinbase policy but a local exchange similar to coinbase that I am using also prohibits the use of their wallet in storing coins that is accumulated thru gambling.
What they do is they give a notice first to a user who violates their TOS and asks them to withdraw the money first before they lock the account. I don't know if coinbase also will do that.
Safest option for you is to use a different wallet if you are accepting coins from gambling or use a mixer like cryptomixer to clean the coins you are receiving in your coinbase wallet so the trace of it being from a gambling site will be wiped off.