yeah bro i mean its hard to really expect yourself to keep all your gains.. while on you are in an androgenic and anabolic state.. when you come off you lose that..
so to answer your question the best way to keep as much gains as possible is to supplement, eat a lot of anabolic food (cage free eggs are the #1 anabolic food out there), and keep working out.
over time your goal is to keep improving year to year. its totally normal and okay to take a step back and then take 2 steps forward.. you are gonna have personal issues that come up, injuries, etc that come up.. so you need to accept the fact you aren't just gonna keep improving all the time