Do I have to physically return a gym to retrieve a pokemon when the gym is defeated?
Solution 1:
No you do not! It returns to you automatically. As of Android version 0.35.0/iOS version 1.50, ousted defenders return to you with 0 HP, per the patch notes.