; (II) the stay of removal is no longer in effect; or (III) the alien is returned to the custody of the Secretary. (iii) Mandatory detention for certain aliens In the case of an alien described in subparagraphs (A) through (D) of section 236(c)(1), the Secretary shall keep that alien in detention during the extended period described in clause (i). (iv) Sole form of relief An alien may seek relief from detention under this subparagraph only by filing an application for a writ of habeas corpus in accordance with chapter 153 of title 28, United States Code. No alien whose period of detention is extended under this subparagraph shall have the right to seek release on bond. ; (4) in paragraph (3)— (A) by adding after If the alien does not leave or is not removed within the removal period the following: or is not detained pursuant to paragraph (6) of this subsection ; and (B) by striking subparagraph (D) and inserting the following: (D) to obey reasonable restrictions on the alien’s conduct or activities that the Secretary prescribes for the alien, in order to prevent the alien from absconding, for the protection of the community, or for other purposes related to the enforcement of the immigration laws. ; (5) in paragraph (4)(A), by striking paragraph (2) and inserting subparagraph (B)