Department stores have been some of the worst-performing stocks during the second half of 2015. Since hitting an all-time high of $73.61 in mid-July, Macy's (M 1.99%) shares have lost more than half of their value.

Nordstrom (JWN 0.34%) stock hasn't done much better, sinking more than 35% from just shy of $80 in mid-July to around $50 today. Shares of Macy's and Nordstrom have both touched multiyear lows in the past week.

M Chart

Macy's and Nordstrom Stock Performance, data by YCharts.

It's natural to be upset when a stock you own plunges rapidly. However, for long-term investors, the recent plunge in shares of Macy's and Nordstrom could actually be a good thing as it will allow both companies to buy back a lot of stock -- accelerating their future earnings-per-share growth.

Nordstrom just got a big influx of cash
For Nordstrom, the timing of its stock meltdown couldn't be better. That's because it recently had a huge influx of cash that it can use for share repurchases.

On Oct. 1, Nordstrom closed on the sale of its credit card receivables portfolio, generating $1.8 billion in net proceeds. It distributed half of that total directly to shareholders through a special dividend of $4.85 per share. It intends to return the other half via share repurchases.

To that end, Nordstrom added $1 billion to its share repurchase program in October -- bringing it to $1.59 billion -- and extended it through March 1, 2017. At the time, I noted that this would be enough to retire about 11% of Nordstrom's outstanding shares.

However, this assumed that the average purchase price would be around $75. With the stock price having fallen dramatically since then, Nordstrom will be able to buy back even more shares.

Nordstrom may be able to buy back 16% of its outstanding shares by early 2017. Photo: The Motley Fool.

During October, Nordstrom spent $105 million to repurchase about 1.5 million shares of stock. This left it with nearly $1.5 billion on its share repurchase authorization at the beginning of November. That's enough to buy back nearly 30 million more shares at $50/share. In total, that would allow Nordstrom to reduce its share count by 16%.

This extra 5% reduction in Nordstrom's share count will increase Nordstrom's earnings per share by 5% in future years. As long as Nordstrom keeps executing its growth plan successfully -- and despite some bumps, it expects total sales to rise 7.5%-8% this year -- this additional EPS growth should help Nordstrom's stock bounce back and exceed its early 2015 highs.

Macy's may have a ton of cash coming soon
Macy's doesn't have that much cash available to buy back stock right now. In fact, it already spent $1.8 billion on share repurchases in the first three quarters of fiscal 2015. Including dividends, it has returned more cash to shareholders this year than its total free cash flow in 2014.

Given that Macy's has reported declines in sales and earnings this year, it might seem that Macy's mistimed the market and spent its available funds on buybacks when its stock was too expensive.

However, Macy's could generate a tidal wave of cash in the next few years by extracting value from its large real estate portfolio. Just in the past few months, it has sold off the upper floors of downtown stores in Seattle and Brooklyn. These moves generated cash proceeds of $65 million and $170 million, respectively, plus another $100 million toward a full renovation of the Brooklyn store.

Real estate sales should allow Macy's to retire a large portion of its stock in the next few years. Photo: The Motley Fool.

Those deals are just a drop in the bucket compared to what Macy's may be able to raise in the next few years. The company has hired real estate firm Tishman Speyer to evaluate redevelopment options for Macy's flagship stores in Manhattan, Chicago, Minneapolis, and San Francisco, as well as monetization opportunities for other stores.

The Macy's Manhattan flagship alone has an estimated value of $3 billion-$4 billion. The Chicago and San Francisco stores may also be worth over $1 billion each. As a result, Macy's may be able to bring in several billion dollars by selling off the upper floors of these buildings for redevelopment as office, condo, or hotel space.

Macy's stock slide has reduced its market cap to just $11 billion. As a result, successful real estate sales (or joint ventures) would allow it to repurchase a substantial portion of its shares in the next several years.

Additionally, Macy's retail business -- while under pressure -- will continue to produce ample free cash flow in the next few years: perhaps as much as $1.5 billion annually. That will provide more firepower for share buybacks.

Macy's and Nordstrom have both hit speed bumps in 2015, but neither one is in serious danger. Yet investors have dumped both stocks in a panic. This makes it a great time for these two department store titans to ramp up their buyback activity to build value for long-term shareholders -- and that's exactly what they're doing.