publish: handling automatic mode exit

generated from commit 753d6bd0064774ac1982740d58f86e77e50c60a5