There’s fetchmail and some other options to move mail from one IMAP sever to another. This can be used to sort of hybrid self host. Gmail would receive your inbound mail, but it would be moved to your self hosted IMAP server, freeing up space on gmail. You’d point your mail client to your server. You could still use gmail for SMTP.
As far as actually self hosting IMAP, you can have multiple receiving servers set up with different priorities (via DNS MX record). Even with just 1, the normal practice is for a sending mailserver to retry for a few days, so you’re unlikely to lose mail with normal self hosting down time (although I guess this can vary a lot for some).
Also if you have Thunderbird remove the email from the server then you can’t have 2 email clients with access to all of the emails (phone + laptop for example).