It is always best to transfer a domain name before it expires so there is no interruption in service and there is no risk of losing ownership of the domain name. If a domain is expired so long that it is removed from the account, it may still be possible to retrieve and transfer it. If the domain is still in your account and in your regular Domains list, you can transfer it as you normally would using the instructions in this link:
If the domain has been expired for a while, it may no longer be in your account. If this is the case, please submit a support ticket using the registrant email address on your account and we will see if we can move the domain back into your account to allow you to transfer the domain.
If the domain has been expired for quite some time, it may have entered a redemption or pending delete state. In these cases, it may not be possible to move the domain back into your account.
Note: When a domain is removed from the account, the DNS records and nameservers are removed as well. You will have to re-add these for the site to work again. Please consult your hosting provider if you are unsure of the records to use.