A $30,000 out-of-court settlement has been reached in a lawsuit brought against Anne Arundel County school officials by the parents of five pupils who were locked in closets as punishment, lawyers said today.

The incidents involving children aged 7 to 12, all pupils at Germantown Elementary School here, occurred in 1981.

As part of the settlement, school officials agreed to adopt court-sanctioned guidelines on how students will be treated when they are removed from classrooms for misbehavior, the lawyers said. Those guidelines, contained in a consent decree signed last Thursday, are the basis for the settlement, they said.

The decree "guarantees . . . that what happened to these children will never happen again," said Alan H. Legum, a lawyer who represented four of the five children.

The settlement came less than two months before the case was to be retried in U.S. District Court in Baltimore. A six-member jury was unable to reach a verdict in a three-week trial last December, and a mistrial was declared.

The parents alleged that their children were isolated in sometimes-darkened closets as punishment for classroom misbehavior. They also alleged that Principal Ralph McCann and vice principal Wayne Miller did not notify them of the punishment and failed to give the children instruction or supervision during their confinement.

The children's attorneys argued that the isolation was cruel and unusual punishment and that the children, who are black, were discriminated against because of their race. The teacher, school officials and principal and vice principal named in the suit are all white.

At the heart of the civil action was the controversial use of a discipline technique known as "in-school suspension." The technique is used in so-called "assertive discipline," which advocates a tough, take-charge approach to teaching. But, as used elsewhere in the country, the program calls for full-time supervision of those being disciplined.

Under the guidelines agreed to last week, Anne Arundel pupils placed on in-school suspension must be supervised at all times and must be allowed out to use restrooms.

The $30,000, to be paid by school system insurers, will cover litigation costs and an unspecified amount to each child.