Three types of rescue can avert extinction in a changing environment