You can exercise an American option at any time, including immediately after you buy it. However, in if there is any time premium remaining in the option, it would make no sense to do so because you are throwing away time premium that could be salvaged by selling the option to close (unless the time premium is less than your closing costs).
Exercising a put when you own the stock or exercising a call when you are short the stock immediately closes both legs at once.
Here's a learning moment for later on:
It does makes sense to exercise a long ITM option whose bid is less than parity, when you don't have a position in the underlying. This avoids the haircut.
Suppose XYZ is $40 and you own the in-the-money Nov $35 call whose B/A quote is $4.80 x $5.20. The intrinsic value of the call is $5 but the best bid is $4.80. That's a 20 cent haircut and if you accept $4.80, the buyer can do a discount arbitrage to close it for $5.00 (more on that in a moment).
You could attempt price improvement by trying to sell at $4.90 or $4.95 but there's little incentive for anyone to give you anything near intrinsic value. And while waiting for a possible trade fill, the price of XYZ could drop and you'd lose some of your call's gain. What to do? Do the discount arbitrage yourself.
Short the stock at $40 and immediately exercise your call to acquire the shares for $35 for a net $5 (less whatever you paid for the call). Short the stock first to avoid leg out risk (it locks in the $5). This is also done with long puts except that you buy the stock first.