The stability of massive main-sequence stars as a function of metallicity