It does depend on the broker. Here is an example account agreement from Etrade, which I think is pretty typical. The agreement says in relevant parts:
E*TRADE has no obligation to exercise any option absent specific instructions from the Account Holder.
So, Etrade says they aren’t required to exercise your options for you if you don’t give them specific instructions to do so on time. You can issue standing instructions to your broker to exercise all in-the-money options contracts on the expiration date for you. But, ETrade also says they can exercise the option for you, even without your instructions, if they choose to do so. To whit:
If the Account Holder has not provided any instructions to ETRADE in accordance with the previous paragraph and they own options that are about to expire “in the money,” ETRADE may, at its sole discretion and without notice to the Account Holder, exercise the option. If such an exercise would require the purchase or sale of the underlying security for which the Account Holder does not have sufficient funds or securities available, ETRADE may, at its sole discretion and without notice to the Account Holder, enter offsetting transactions to close out the position. Although ETRADE has the discretion to take such action, ETRADE is not obligated to do so. In the event that ETRADE exercises an in-the-money options contract for the Account, and in the absence of instructions from the Account Holder, E*TRADE may thereafter close out any resulting positions (e.g., buy-in short positions or sell long positions).
If the option settles in cash, it will automatically be exercised for you and you will just get cash for the difference between the strike price and the closing price of the stock. Most (or possibly all) listed single-stock options in the US are “physically settled,” meaning that shares are delivered as necessary.
If your option is physically settled and if you already have cash in the account to cover the purchase, your ETrade will just buy the stock for you. It’s up to you to choose how long to hold it and when to sell it. You will bear all the risk like any other stockholder.
If you don’t have the cash in your account, ETrade can enter offsetting transactions (and, as a practical matter, they will). That is, they will sell the underlying stock. From your perspective, the option purchase and the stock sale will happen simultaneously. ETrade doesn’t say it in their agreement but there are special market orders that are executed at the closing price. ETrade will likely use one of those orders to sell your shares at the market close price. Thus, when they exercise your option on your behalf, they will already have ordered the sale of the underlying shares. The stock transaction settles the business day after the transaction (T+1) and the option transaction settles two days after exercise (T+2), but when both have settled, you will just have cash in your account reflecting the difference in price between the strike price of the option and the sale price (less any brokerage fees).
In theory, (3) could happen because ETrade could opt to both exercise the option on your behalf but opt not to enter into an offsetting transaction. However, the ordinary processes at any competent broker-dealer won’t let that happen. Perhaps this could happen in times of extraordinary weirdness.
ETA: Added link to account agreement.