reorganize some gateway shutdown code
reorganize some gateway shutdown code

ericflo/Sia,mharkus/Sia,rivine/rivine,mnsl/Sia,ChrisSchinnerl/Sia,rivine/rivine,mtlynch/Sia,NebulousLabs/Sia,mharkus/Sia,mtlynch/Sia,ericflo/Sia,MrStrong/Sia,ChrisSchinnerl/Sia,MrStrong/Sia,mnsl/Sia,NebulousLabs/Sia