Maximum recoverable work in linear thermoelectromagnetism