layer: remove the commit handler when all resource are freed