This paper considers the problem of finding the nearest \(\Omega \) -stable pencil to a given square pencil \(A+xB \in \mathbb {C}^{n \times n}\) , where a pencil is called \(\Omega \) -stable if it is regular and all of its eigenvalues belong to the closed set \(\Omega \) . We propose a new method, based on the Schur form of a matrix pair and Riemannian optimization over the manifold \(U(n) \times U(n)\) , that is, the Cartesian product of the unitary group with itself. While the developed theory holds for any closed set \(\Omega \) , we focus on two cases that are the most common in applications: Hurwitz stability and Schur stability. For these cases, we develop publicly available efficient implementations. Numerical experiments show that the resulting algorithm outperforms existing methods.