On Friday, Costco Wholesale Corporation (NASDAQ:COST) announced that it will pay out a special dividend of $5 per share later this month, in addition to its regular quarterly dividend of $0.355 per share.

Investors applauded the move. In fact, since the announcement, Costco shares have surged by more than 10%, reaching a new closing high of nearly $156 on Wednesday.

COST Price Chart

Costco One-Week Stock Chart. Data by YCharts

While the company plans to continue expanding its global footprint in the coming years, it generates plenty of cash to fund that growth. This special dividend represents a sensible return of capital to shareholders.

A reliable cash cow
In recent years, Costco has been opening about 30 new warehouses annually, thereby growing square footage by 4% to 5% each year. It is also working on a significant IT modernization project to make its stores more efficient and to grow e-commerce.

To support these initiatives, Costco has spent about $2 billion on capital expenditures for each of the past two years. In fiscal year 2015, it expects spending to rise to $2.5 billion to $2.7 billion. However, operating cash flow has also been growing steadily and surpassed $4 billion for the last four quarters.

COST Cash from Operations (TTM) Chart

COST Cash from Operations (TTM), 2010-present; data by YCharts

This means that Costco can easily expand its CapEx program, while generating enough cash pay more than $600 million in annual dividends.

Freeing up cash
Given that Costco churns out cash so reliably even while funding its expansion, the company only needs a modest amount of cash on hand to fund working capital requirements. But as of the end of fiscal year 2014, Costco had $7.3 billion of cash, cash equivalents, and short-term investments.

Of this amount, $1.4 billion is not readily available, consisting of credit card and debit card receivables that have not yet been passed along from the card companies to Costco. Another $1.8 billion is considered indefinitely reinvested outside the U.S., which allows Costco to avoid paying U.S. corporate taxes on that sum.

The offshore cash pile was even bigger until recently. In late 2014, Costco decided to repatriate $1.2 billion from Canada as growth in the region is slowing, and it only faced a modest tax bill of $15 million for bringing that money home.

Costco repatriated $1.2 billion of cash from Canada late last year. Photo: The Motley Fool

This move increased the cash available for shareholder returns from just under $3 billion to more than $4 billion and was likely a key consideration behind the announcement.

Dividends or buybacks?
This is not the first time that Costco has returned excess cash to shareholders through a special dividend. The company made a $7 per share payout in late 2012, in advance of a scheduled increase in the tax rate for dividends. However, Costco could have returned the cash to shareholders through a share buyback as well.

One advantage of buybacks is that -- unlike dividends -- they do not incur an immediate tax bill. By reducing the share count, buybacks increase the value of the remaining shares. That should increase capital gains, but those gains can compound tax free until investors sell their position (for investors holding Costco shares in tax-advantaged accounts, there is no tax benefit for share buybacks compared to dividends.

A potential downside of share buybacks is that historically, companies tend to have bad timing when repurchasing their own shares. Indeed, Costco stock recently hit fresh highs, and it currently trades for 30 times projected fiscal year 2015 earnings.

That may be a fair price but it's certainly not a bargain. Costco was probably right to let its shareholders decide whether they want to spend their $5 payout elsewhere or to reinvest the money in more Costco stock.