Close service if setId failed

Close service after setId