der section 1292. Although an order enforcing a forum selection clause would appear to be interlocutory, we are convinced that it falls within that “ ‘small class’ of decisions excepted from the final-judgment rule by Cohen [v. Beneficial Loan Corp., 337 U.S. 541, 546 [69 S.Ct. 1221, 1225, 93 L.Ed. 1528] (1949) ]....” Coopers & Lyb-rand v. Livesay, 437 U.S. 463, 468, 98 S.Ct. 2454, 2457, 57 L.Ed.2d 351 (1978).
In Coopers & Lybrand, the Supreme Court held that to come within the Cohen exception “the order must conclusively determine the disputed question, resolve an important issue completely separate from the merits of the action, and be effectively unreviewable on appeal from a final judgment.” Id. at 468, 98 S.Ct. at 2458. The district court’s order meets all three criteria. The order conclusively determines enforceability of the clause, an issue completely separate from the merits of Pelle-port’s breach of contract claim. The order is otherwise unreviewable, because it puts the parties out of federal court, and the district court’s decision would be res judica-ta in the state court. See Moses H. Cone Memorial Hospital v. Mercury Construction Corp., 460 U.S. 1, 103 S.Ct. 927, 934 & n. 10, 74 L.Ed.2d 765 (1983).
In Moses H. Cone Memorial Hospital, the Supreme Court held that an order refusing to exercise federal jurisdiction is appealable under section 1291 as collaterally final because the decision is such that appellant is “effectively out of court.” Id. 103 S.Ct. at 933-34 & n. 8, quoting Idlew-ild Liquor Corp. v. Epstein, 370 U.S. 713, 715 n. 2, 82 S.Ct. 1294, 1296 n. 2, 8 L.Ed.2d 794 (1962). Moses H. Cone Memorial Hospital involved the enforceability of an arbitration clause in a contract between the hospital and construction company. The hospital brought suit in state court for a declaratory judgment that there was no right to arbitration. While the state court action was pending, the construction company filed a diversity action in federal district court seeking an order compelling arbitration. The district court stayed the federal action on the ground that the two suits involved the identical issue of arbitrability. On appeal from the stay, the hospital contested the court of appeals’ authority to review the order. In recognizing the appellate court’s jurisdiction, the Supreme Court held that:.
a stay order is final when the sole purpose and effect of the stay is precisely to surrender jurisdiction of a federal suit to a state court.
103 S.Ct. at 935 n. 11.
Here too, the sole purpose of the remand is to surrender jurisdiction to the state court. We conclude, therefore, that the district court’s order is reviewable as a collaterally final order under section 1291. Cf. Coastal Steel v. Tilghman Wheelabrator Ltd., 709 F.2d 190, 195-97 (3d Cir.), cert, denied, — U.S.-, 104 S.Ct. 349, 78 L.Ed.2d 315 (1983) (holding an order denying a motion to enforce a forum selection clause reviewable as collaterally final under § 1291).
C. Subject Matter Jurisdiction In District Court
Our first task in reviewing the district court’s order enforcing the forum selection clause is to determine whether the court had subject matter jurisdiction to decide the issue. As discussed earlier, the district court bypassed the issue of whether Pelleport’s inclusion of Doe defendants in its complaint defeats diversity between Pelleport and Budco. Apparently, the court believed that its decision to enforce the forum selection clause obviated any need to address this problem. But, as noted earlier, the two decisions are separate. To reach the contract clause issue, the court had to have subject matter jurisdiction. The district court’s failure to address the issue, however, does not necessarily require remand. We may affirm the district court’s judgment on any basis appearing in the record. See Mollnow v. Carlton, 716 F.2d 627, 628 n. 1 (9th Cir.1983), cert. denied, — U.S. -, 104 S.Ct. 1595, 80 L.Ed.2d 126 (1984). Because we find that the inclusion of the Does does not defeat diversity, and diversity of citizenship between Pelleport and Budco is clear from the record, we see no reason to remand to