Stealth Rock will stay in play until your opponent uses either Rapid Spin or Defog. Pokémon with ability Magic Guard are not affected by Stealth Rock.