hook cleanup and clear buffer on restart