Countries with strict immigration policies often resort to deportation measures to reduce their stocks of illegal immigrants. Many of their undocumented foreign workers, however, are not deported but rather choose to return home voluntarily. This paper studies the optimizing behavior of undocumented immigrants who continuously face the risk of deportation, modeled by a stochastic process, and must decide how long to remain in the host country. It is found that the presence of uncertainty with respect to the length of stay abroad unambiguously reduces the desired migration duration and may trigger a voluntary return when a permanent stay would otherwise be optimal. Voluntary return is motivated by both economic and psychological factors. Calibration of the model to match the evidence on undocumented Thai migrants in Japan suggests that the psychological impact of being abroad as an illegal alien may be equivalent to as large as a 68% cut in the consumption rate at the point of return.