Castro started more games at shortstop than any other player in 2008 for the Orioles. He became a free agent at the end of the season and on January 4, , he signed a minor league contract with an invitation to spring training with his original team, the Los Angeles Dodgers. He spent the season as a backup infielder and then filed for free agency again. Castro agreed to a one-year deal with the Philadelphia Phillies on November 24. Castro temporarily replaced Jimmy Rollins at shortstop after Rollins suffered a right calf injury. Playing third base, Castro fielded the ground ball and threw to first, completing the 27th and final out of Roy Halladay's perfect game. Castro was released by the Phillies on July 17, 2010, and returned to the Dodgers on a minor-league contract on July 27, 2010. The Dodgers called him up to the Majors on August 11, 2010. He appeared in one game and was designated for assignment on August 21. The Dodgers had intended to recall him when rosters expanded in September, but he chose to remain home to attend to an ailing family member. He became a free agent after the season but re-signed with the Dodgers on a minor league contract that included an invitation to spring training. He was assigned to the AAA Albuquerque Isotopes. On May 13, 2011, he had his contract purchased by the Dodgers. After appearing in seven games, during which he was 4 for 14, he was again designated for assignment on June 6. He retired from baseball on July 10, 2011. Over 17 years in the major leagues, he batted .229/.268/.327. Castro agreed to a new position as a special assistant to the General Manager with the Dodgers, with involvement in player development and talent evaluation. He was also a coach with the Mexico national baseball team in the 2013 World Baseball Classic. Castro was the Dodgers minor league infield coordinator in 2015. In 2016, he was added to the Dodgers major league staff in the newly created post of Quality Assurance Coach. After the 2017 season, he left the Dodgers to become the director of operations for the Tijuana Toros in the Mexican League. In 2018, Castro returned to the Mexican Pacific League to manage the Águilas de Mexicali, his second stint as manager of the club. In 2019, Castro was announced as manager for Team Mexico at the 2019 WBSC Premier12 tournament.