Not long ago, it would have taken more than half an hour to get nearly 300 students ready for the annual picture in the quad of the private Queen Anne School in Prince George’s County. This year, there were 94 students, boys and girls in grades 6 through 12, and they set up quickly for the photo shoot.

“We could all just fit in one spot in the gym,” said Kathy Cunningham, the school’s academic dean. Cunningham has been involved with Queen Anne School since 1994, as a parent, teacher and administrator. “It’s moments like these when you realize how small we’ve become.”

Next month, the school of seven small buildings on 54 acres of lush land on Oak Grove Road in Upper Marlboro will shut down after a long period of financial difficulties and dwindling enrollment. The closure of the church-affiliated school, founded 47 years ago by St. Barnabas Episcopal Church, reflects changing times for the county as well. The church plans to lease the campus to the county school system, which is expected to use it for a charter school.

In 1964, the Queen Anne School started with 11 students inside a small brick house surrounded by corn and tobacco farmland. The next year, there were 30 students, each paying about $600.

“Its reputation spread a little bit, and grew bit by bit,” the school’s founder, the late Rev. Howard Arnold, said in a 1984 interview.

Over time, the school added a library and a science laboratory. An old barnyard was turned into a student lounge. The school depicted itself as an oasis of academic rigor, with the feel of a college campus. There were no school bells. Students who crossed the quad sometimes encountered chickens and beagles.

The school never barred black students, but none attended for years. The 1974 yearbook, the school’s first, showed 20 seniors — none African American. There were no black seniors in the 27-member class of 1984.

In those years, the county’s public schools were undergoing a profound transformation because of a court-ordered racial desegregation initiative and a simultaneous demographic upheaval in the county. Many white students during that era left the public system for private schools such as Queen Anne.

But by 1994, roughly a third of the 21 seniors at Queen Anne were black, and school leaders welcomed the diversity. By 2004, about 40 percent of students were black. Now the school has only a handful of white students.

At its peak, tuition for the middle grades was $18,500; for upper grades, $19,500. But the price was lowered by thousands of dollars in recent years in an effort to find a market niche in a county shaken by foreclosures and economic troubles.

To save money, the school cut middle school sports and lacrosse. Teachers swallowed a 15 percent pay cut. Eventually, the board of trustees lowered tuition in hopes of preventing more kids from leaving.

“I think there was a misconception about our families and that they could still afford this place,” said Christiana Holyer, the head of the school. “But they were families where both parents were working.” Money for them, she said, was tight.

In January, the church began moving to close Queen Anne. The faculty sent letters to parents explaining the decision.

Last-ditch alumni efforts to save the school, including a fundraising campaign, a retooled Web site and YouTube videos, fell short.

Students said the closure took them by surprise.

“At first, we didn’t realize things were that bad,” said William Johnson, 17, the student body president, who is headed to the New School in New York in the fall.

In the final weeks, faculty kept the classroom routine as normal as possible. Upperclassmen gleefully boogied at the prom, and teachers vowed that final exams would be taxing.

At a recent event for seniors and alumni, Holyer gave a slideshow of the kids growing up at their school, to the tune of pop songs about leaving and loss.

Valerie Reuther, Class of ’79, watched the show. She said that the faces looked different from those in her era but that the spirit of the school never changed.

“You don’t realize it until you’re older,” she said. “But one day, they’ll understand how unique all this was.”

Samaria Johnson, 18, grew emotional as classmates laughed at pictures from productions of “The Wiz” and “Singin’ in the Rain” and of the track team jumping hurdles.

“At first, I thought it was cool to be in the last class of a school,” said Johnson, who will attend the University of Alabama. “I’ve gone to several private schools, and I always hated the ‘legacy’ kids. But now, here I am envisioning that my own children would go to this school. Now it’s not going to happen.”