Yahoo has closed a deal to sell a portion of its stake in Chinese Internet company Alibaba, netting $4.3 billion for the company.

In a memo to employees, Yahoo CEO Marissa Mayer says she will return $3.65 billion of that money to shareholders.

Yahoo will be keeping $650 million.

"This outcome is terrific for Yahoo," writes Mayer.

"It generates liquidity to create substantial value for our shareholders, while retaining a meaningful amount in the company to invest in our future."

"Also, because we still own 23 percent of Alibaba's common stock, we have the opportunity to benefit from future upside when Alibaba IPOs."

Giving a couple billion dollars back to Yahoo shareholders from this sale was the plan before Mayer took over Yahoo. A couple weeks after she joined, Mayer put out of an SEC filing saying she was reconsidering the move.

We liked the idea of keeping the money. Giving Yahoo shareholders the money now will appease them, and even drive the stock price up, but it will not leave Yahoo fundmanetally better off the way a smart investment in a new product or acquisition would.

Oh well. Lots of today's Yahoo shareholders are going to be very happy about the news. The stock is already spiking.

Yahoo is also working on selling a portion of its Yahoo! Japan stake. In the past, sources close to Yahoo have said is more likely those proceeds will remain in Yahoo's coffers, ready for future investments.

Here is the memo:

Hi Yahoos,

Today we reached a very important milestone in our relationship with Alibaba - we closed a transaction selling some of our Alibaba Group shares for $7.6 billion. After taxes and fees, we have received approximately $4.3 billion. We'll be issuing a press release imminently.

We have reviewed our strategy for the proceeds with the board of directors and have agreed that we will be returning approximately $3.65 billion to shareholders. This amount includes a 'down payment' of $646 million that we made over the past few months in the form of stock buybacks since the transaction was announced, as well as an additional $3 billion from today's proceeds.

This outcome is terrific for Yahoo!. It generates liquidity to create substantial value for our shareholders, while retaining a meaningful amount in the company to invest in our future. Also, because we still own 23 percent of Alibaba's common stock, we have the opportunity to benefit from future upside when Alibaba IPOs.

I'd like to take a moment to thank Tim Morse, Ron Bell and everyone on their teams who worked on this deal. Today's announcement is the result of years of savvy investment, hard work, creativity and tenacity in order to navigate an extremely complicated set of legal and tax parameters. The team's execution has been excellent and positions Yahoo! well for future growth. Congratulations!

In the last few months, we have built great momentum around our company.

Thank you all for staying focused on our users, advertisers, and shareholders.