This is one of numerous appeals from orders of the district court in the litigation arising from the EXXON VALDEZ oil spill. The appellants are 339 plaintiffs in individual actions filed in the Alaska state court and removed by appellees Exxon Corporation and Exxon Shipping Company to the district court in February 1992. Some (but not all) of these appellants moved for remand and, on the district court’s denial of their motions, appealed. This court, in Eyak Native Village v. Exxon Corp., 25 F.3d 773, 782 (9th Cir.), cert. denied, — U.S. -, 115 S.Ct. 351, 130 L.Ed.2d 307 (1994), - U.S. -, 115 S.Ct. 778, 130 L.Ed.2d 673, — U.S. -, 115 S.Ct. 779, 130 L.Ed.2d 673 (1995), *431reversed the district court’s order and remanded the actions.
While the appeal in Eyak was pending, district court proceedings continued in appellants’ cases. Appellees attempted to obtain discovery from appellants. Appellants failed to comply with repeated discovery requests and moved to dismiss their actions without prejudice under Fed.R.Civ.P. 41(a)(2), for the purpose of pursuing their claims as class members in pending class actions. In November 1992, the court denied appellants’ motions, adopted the special master’s recommendations, and pursuant to Rule 37, dismissed appellants’ actions with prejudice for failure to make discovery. In May 1994, the court directed entry of final judgment against appellants (among others) pursuant to Rule 54(b).1 We have jurisdiction under 28 U.S.C. § 1291 and affirm.
SUBJECT MATTER JURISDICTION
At the threshold, we confront the question whether the district court had jurisdiction to enter the orders that are the subject of this appeal. Of the 339 appellants, 207 were parties oü seven actions in which appeals were taken from the denial of the remand motions.2 In Eyak we held that, because the notices of removal were untimely, those actions had not been properly removed. The remaining 132 appellants were parties to actions in which removal was not challenged.3
The Eyak appellants contend that the district court lacked jurisdiction to enter the judgment of dismissal. Their focus is primarily on the district court’s order, entered following remand from this court, retaining jurisdiction of the actions on the ground that diversity of citizenship had come into existence while the appeal was pending. Because the district court acted within its authority when it rendered the judgment appealed from, we need not consider the validity of its jurisdictional ruling. A court has jurisdiction to make orders necessary for “the maintenance of orderly procedure,” even if its determination of jurisdiction later turns out to be mistaken. Willy v. Coastal Corp., 503 U.S. 131, 112 S.Ct. 1076, 117 L.Ed.2d 280 (1992) (upholding Rule 11 sanctions before court of appeals determined district court lacked subject matter jurisdiction). “A final determination of lack of subject-matter jurisdiction of a case in a federal court ... does not automatically wipe out all proceedings had in the district court at a time when the district court operated under the misapprehension that it had jurisdiction.” Id. at 137, 112 S.Ct. at 1080. The sanctions imposed here under Rule 37 were collateral to the merits of the actions, just as the Rule 11 sanctions were in Willy; though they terminated the actions, they “[did] not signify a district court’s assessment of the legal merits of the complaint.” Id. (quoting Cooter & Gell v. Hartmarx Corp., 496 U.S. 384, 396, 110 S.Ct. 2447, 2456, 110 L.Ed.2d 359 (1990)); see also Heinrichs v. Marshall and Stevens, Inc., 921 F.2d 418, 420-21 (2d Cir.1990) (upholding Rule 37 sanctions imposed after dismissal of complaint on summary judgment). Hence, we conclude that the district court had jurisdiction to render its judgment.
DENIAL OF LEAVE TO DISMISS WITHOUT PREJUDICE
Appellants’ first ground of appeal is that the district court abused its discretion in denying motions for voluntary dismissal pursuant to Rule 42(a)(2).4 In support of their motions in the district court, appellants argued that they would be prejudiced by having to “continue prosecution of an action not of their choosing, with counsel not of their *432choosing.” However, plaintiffs filed their individual actions in state court after the state court classes had been certified and pursued them, for some eighteen months. In this court, appellants do not dispute the court’s characterization of their motions as an attempt to avoid discovery; the motions were filed within a month of the master’s advising them that they would face Rule 37 sanctions, including possible dismissal, if they continued to refuse to respond to discovery. They contend that they have a substantive right to litigate their claims in the class actions and that defendants would not have been prejudiced by a dismissal without prejudice.
We review the district court’s denial of the Rule 42(a)(2) motion for abuse of discretion: “[A Rule 42(a)(2)] motion is addressed to the district court’s sound discretion and the court’s order will not be disturbed unless the court has abused its discretion.” Stevedoring Services of America v. Armilla Intern. B.V., 889 F.2d 919, 921 (9th Cir.1989). In its order the court stated three reasons for denying the motions:
(1) The court considered most of the motions to be “thinly-veiled attempts to avoid discovery”;
(2) Because the future viability of the classes certified by the state court was problematic, the court found that each plaintiff should remain a named plaintiff in at least one action to avoid a future need for substantial refiling of actions should the classes be decertified;
(3) Allowing dismissal after the defendants had spent two and a half years and substantial amounts of money to obtain discovery would prejudice the defendants.
The district court’s reasoning was sound; we therefore conclude that the court did not abuse its' discretion in denying the motions.
DISMISSAL OF THE CASES UNDER RULE 37
The heart of the appeal is the court’s order dismissing the appellants’ actions for failure to respond to appellees’ discovery requests. Under Rule 37(b)(2)(C), if a party fails to obey an order to provide discovery, the court may dismiss the action, “rendering a judgment by default against the disobedient party.” Fed.R.Civ.P. 37(b)(2)(C). “We review sanctions imposed by a district court for abuse of discretion and will not reverse absent a definite and firm conviction that the district court made a clear error of judgment.” Halaco Engineering Co. v. Costie, 843 F.2d 376, 379 (9th Cir.1988). Dismissal, however, is authorized only in “extreme circumstances” and only where the violation is “due to willfulness, bad faith, or fault of the party.” United States v. Kahaluu Const., 857 F.2d. 600, 603 (9th Cir.1988) (quoting Fjelstad v. American Honda Motor Co., Inc., 762 F.2d 1334, 1338 (9th Cir.1985), and Wyle v. R.J. Reynolds Industries, Inc., 709 F.2d 585, 591 (9th Cir.1983)).
The history of these proceedings reflects a virtually total refusal by appellants over a period of more than two years to comply with discovery obligations and orders. Pursuant to the discovery plans adopted by the state and federal courts in 1990, appellees served interrogatories calling for the identification of witnesses and documents. Lengthy but fruitless discussions to obtain responses followed during the next year and a half. Meanwhile, appellees served damage interrogatories called for by the discovery plan. In 1992, when the defendants had received no responses and none appeared forthcoming, defendants filed motions to dismiss, which the master converted into motions to compel, ordering appellants to respond to both sets of interrogatories. Appellants were warned repeatedly by both the court and the master that failure to comply would result in dismissal. When appellants continued to refuse to comply, the master, in December 1992, recommended dismissal. He found that though they had been repeatedly warned, their continued noncompliance invited dismissal since appellants had provided either no discovery or so little as to be tantamount to no discovery at all. The master further found that sanctions other than dismissal would be unavailing, would not rectify the prejudice appellees had suffered, and would not deter sanctionable conduct in the future by other parties in this litigation which involves some 4,000 direct-action plain*433tiffs. In January 1993, the-court adopted the master’s findings and recommendations and dismissed the actions of appellants.
It is undisputed that the failure to respond to discovery and to comply with the orders to do so was knowing and deliberate. Appellants argue that the discovery was unduly burdensome, but there is no record (and no claim) that they ever sought relief from any of the discovery requests.
A district court must consider five factors in determining whether the circumstances warrant dismissal:
(1) the public’s interest in expeditious resolution of litigation;
(2) the court’s need to manage its docket;
(3) the risk of prejudice to the defendants;
(4) the public policy favoring disposition of cases on their merits; and
(5) the availability of less drastic sanctions.
Thompson v. Housing Auth. of City of Los Angeles, 782 F.2d 829, 831 (9th Cir.), cert. denied, 479 U.S. 829, 107 S.Ct. 112, 93 L.Ed.2d 60 (1986). The district court’s findings address these factors. We are satisfied that it did not abuse its discretion.
The EXXON VALDEZ litigation involved scores of lawsuits and thousands of litigants. Management of the litigation, and its expeditious resolution, required that discovery be conducted in an orderly and timely manner. Although these cases involve only a fraction of the parties in the litigation, the court properly considered the importance of sanctions as a deterrent in litigation involving thousands of plaintiffs. See Founding Church of Scientology v. Webster, 802 F.2d 1448, 1458 (D.C.Cir.1986), cert. denied, 484 U.S. 871, 108 S.Ct. 199, 98 L.Ed.2d 150 (1987); United States v. Sumitomo Marine & Fire Ins., 617 F.2d 1365, 1369 (9th Cir. 1980). The appellants’ total failure to respond to discovery and the time consumed by attempting to secure compliance prejudiced appellees. Adriana Intern. Corp. v. Thoeren, 913 F.2d 1406, 1412 (9th Cir.1990), cert. denied sub nom. Lewis & Co. v. Thoeren, 498 U.S. 1109, 111 S.Ct. 1019, 112 L.Ed.2d 1100 (1991); Wanderer v. Johnston, 910 F.2d 652, 656 (9th Cir.1990).
Before invoking the drastic sanction of dismissal, the court and master warned appellants that continued noncompliance would result in dismissal. It denied earlier motions to dismiss and imposed costs on plaintiffs as a lesser sanction. In determining that dismissal was appropriate, it specifically considered the need to deter others of the 4,000 plaintiffs in the litigation. See Adriana Intern. Corp., 913 F.2d at 1412-13; Malone v. U.S. Postal Serv., 833 F.2d 128, 132 n. 1 (9th Cir.1987).
The overwhelming weight of the factors supporting dismissal overcomes the policy favoring disposition of cases on their merits. But even that policy lends little support to appellants, whose total refusal to provide discovery obstructed resolution of their claims on the merits.
Appellants argue that all of these problems could have been avoided had they been permitted to dismiss their eases and pursue their claims in the class actions. The argument is not persuasive. As noted above, appellants filed their individual actions after class certification and pursued them . for about a year and a half. Only when it became apparent that the master would recommend dismissal as a discovery sanction did they move for voluntary dismissal.
The judgment is AFFIRMED.
.In No. 94-35650, there are 14 appellants, one of whom is not properly before the court because he did not oppose appellees’ motion to dismiss (Hughes P-3074). The other 14 filed timely notices of appeal. In No. 94-35671, appellees, though expressing uncertainty with respect to the identity of the individual appellants, proceeded on the assumption, not challenged by appellants, that they are the parties identified as plaintiffs in Exhibit A attached to the notice of appeal. It thus appears that there are 339 appellants.
. Cases No. A92-143, A92-168, A92-182, A92-195, A92-209, A92-224, and A92-353.
. Cases No. A89-14 and 91-137. Case No. 91-143, referred to by appellees, is not a part of this appeal.
. Only 11 of the 339 appellants had a Rule 41(a)(2) motion denied.