So long as:
- your mothership has room for additional goons, and
- the beacon to the current area is active
You can simply order your ships to repair from the Tactics pane (F2 or Spacebar). This will make them immediately go back to the mothership for, well, repairing; in addition they will also drop excess goons (and rez).
You determine how many goons are excess goons with the "Desired Surplus Crew" slider in the Hangars pane (F3).
If the beacon has been destroyed, your only option to leave the sector is a mass retreat; as a result you'll have to leave all escape pods to their gloom destiny. If there's no beacon because you're at your mothership hideout, you can still order your ships to repair but it'll take longer as the ships need to physically travel the distance to and from the mothership back and forth in the process. To avoid this you can refit your ship by changing its loadout slightly from the Hangars panel.