How to recover a deterministic wallet offline? I know that in the case of electrum there is a gap limit and it will keep generating addresses until it finds a number of consecutive empty addresses equal to the gap limit.

What about if I want to recover my wallet using my seed offline, suppose that electrum servers are not working and I want to recover my wallet. How can electrum know when to stop generating addresses noting that it has no access to the blockchain since the servers are down.
Let's assume a BIP-32 compliant HD wallet is also BIP-39 and BIP-44 compliant.

Let's next assume that when you first configured your BIP-39 compliant HD wallet it provided you the following set of words to be used to reconstitute your master seed: small cereal crazy ahead move never galaxy draft draw plunge sort identify embark clerk hard wagon clever torch cruel income episode any debris puppy.  Additionally, let's also assume the wallet requested that you enter an additional BIP-39 related salted password that will be set to I'mAbadASS for discussion purposes.

A 512 bit root seed m could be obtained for the situation above by issuing the following bitcoin-explorer (bx) command: 

% echo "small cereal crazy ahead move never galaxy draft draw plunge sort identify embark clerk hard wagon clever torch cruel income episode any debris puppy" | bx mnemonic-to-seed -l en -p "I'mAbadASS" 
c64364d5a4175ff506620c3b788633063a2b3808579cd0f074503a365d283fc3a0bfb50d98f1293828e868e865054eff94261c206d35138689ce97efef9ada9c

BIP-44 compliant HD trees use the m/purpose'/coin_type'/ account'/change/address_index convention to derive private keys and associated addresses.  Let's then assume the wallet only has one account 0.  For the Bitcoin the coin_type the private key tree would look like m/44'/0'/0'/c/i where c can be 0 or 1 and i is an index used to synthesize the i-th extended private key, i-th extended public key or address.  

m/44'/0'/0'/1/0 could then be synthesized as follows:

% echo $root_seed | bx hd-new | bx hd-private -i 44 -d | bx hd-private -i 0 -d | bx hd-private -i 0 -d | bx hd-private -i 1 | bx hd-private -i 0
xprvA3zHj8cyzFJiKAXiqdLqrdjUvMqdxUbrpSpDGfxHA15uk2j3fUknu2GN6rSYpPc3QDhALvLBNtKfNGQTLYLNFJD5FKnuFbDPRoBp5TAHFba

From the resulting extended private key (ext_prv_key) above, the corresponding public address and private key can be found.

% echo $ext_prv_key | bx hd-to-address
1BLQ28VdYxJ4Y89fjpbNP5ihUvy2hMkGgq

Then determine if any funds have been sent to the address above by issuing % bx fetch-balance 1BLQ28VdYxJ4Y89fjpbNP5ihUvy2hMkGgq on a computer attached to the Internet or have a very fresh bitcoin-server full node server available for your bx on your private computer that is offline.  

If funds are present, to obtain the private keys to import into another wallet try:

% echo $ext_prv_key | bx hd-to-wif
L3KsdTwat69cMtLTJE4W2G77SgazLGqhzfvMkYQsuwMC96tr3Tj8 

The qrencode command can receive the piped text output immediately above to synthesize a QR image for a smart cell phone or tablet based wallet to easily import from an offline key synthesis computer that retains a network air-gap.

% echo $ext_prv_key | bx hd-to-wif | qrencode -o QRwif.png

See how-to-import-a-hd-wallet-from-an-extended-private-key for more Electrum specific details.