DES MOINES, Iowa (AP) _ To the end, M.J. Kelly was sure the Commercial State Bank in Afton would survive. After all, he had worked there since he was 12, stoking the furnace and swabbing floors for his father, who helped establish it in the Depression era.

Kelly financed a $1.2 million buyout of the bank in 1981 and was its president. But now, at age 45, he has lost his investment and is looking for work. The bank was closed by the state and has reopened under new ownership.

''We were believing right up until the last minute that it wasn't going to happen,'' he said. ''It's just like a death in the family.''

Kelly isn't grieving alone. State banking officials had closed seven banks in Iowa by mid-June, more than any other state except Nebraska, which has lost the same number. The two farm states together account for nearly a third of the U.S. banks shut down this year.

For most customers, a bank failure is little more than a nuisance. Deposits are federally insured, and in Iowa so far new buyers have re-opened all the banks within days.

But bank presidents have no protection.

At six of the banks, the presidents or their families had owned most or all of the stock. They also lost their jobs and say they have little chance of finding other banking work.

''As soon as they find out who I am and what happened here, that's it,'' said Duane Schofield, 49, former president of the failed Peoples State Bank in Odebolt. ''One fellow told me, 'Well, I can't take you because I'd have a difficult time explaining why I hired someone from a failed bank.'''

He has three children living at home, and the family's only income is his wife's one-day-a-week job.

Five of the seven former presidents of the failed Iowa banks were interviewed by The Associated Press. One declined interviews and another was out of the country.

They said they have been overwhelmed by community support.

''When it's over with, you feel quite low,'' said Bob Sweet, 55, president of the Story County State Bank when it collapsed. ''The strength you get is from the people. I've received so many letters, so many calls and visits. ... I never expected this type of response.''

''They've been behind me 100 percent,'' said Don Curry, president of the Farmers Savings Bank in Massena when it went down. ''It's kind of hard when 30 years of work goes down the tube. It's all the assets I had.''

Unlike the others, Curry has a full-time job, running a family insurance and tax-preparation business formerly operated by his brother, who has since, ironically, taken a position in the new bank.

Aside from Curry, the only one not looking for work is Charles Riter, 65, president of the Inwood State Bank when it went down. After buying controlling interest in the bank in 1980 and seeing its assets gutted by a sour farm economy, the Rock Rapids lawyer retired to Santa Fe, N.M.

''It caps the end of my career,'' he said.

The Federal Deposit Insurance Corp., which insures deposits up to $100,000 and steps in when a bank folds, blames the failures on the bankers, not the farm economy. It reasons that if the economy was at fault, then other banks would have fallen.

''There has to be some other cause, such as poor direction of the board,'' said Paul Wiechman, assistant regional director of the FDIC in Kansas City.

''Every time you make a loan, you should have some reasonable means of repayment,'' he said. The seven Iowa banks failed this test, he said.

The presidents disagreed, saying their loans were prudent and that neighboring banks aren't doing very well, either.

They said they were caught by the same factors that have driven hundreds of farmers off the land - eroding land values and commodity values plus high interest rates, which made it difficult for farmers to pay back loans.

A recent study by the Federal Reserve Bank in Chicago found that Iowa farm land lost 41 percent of its value since 1981.

''We had nothing but optimism in 1981,'' Kelly said. ''Our customers were showing signs of stress, but it all had to work out. You knew it would. It would have to.''

''Our borrowers had depressed collateral, but they were good hard-working people who knew how to farm,'' Kelly said. ''But the credit crunch got the better of them and they had no crops. We've been wiped out here three years in a row.''

''We were basically trying to work with these people, not put them out of business,'' Curry said.