Just the layer? What good would that do, the data would still be intact. Or do you mean also the data associated with the layer? Anyway for the literal interpretation of your question its pretty simple just do use mostly the same code as you had previously:
for ($layer in stringArrayRemoveExact( {"defaultRenderLayer"}, `ls -type renderLayer`)){
if (! getAttr($layer+".ri.rndr"))
delete $layer;
}
As for deleting the resources associated with the layers that's a bit tricky as you need to check for what other layers items are in and maybe what other associations they do have. This can not be done quite as easily as it requires quite a bit of special cases to be handled properly.
PS; you may want o add a renderLayerCleanup at the end of the script
PPS: the reason you don't want to use age old threads is that the system will drop the tread out of visibility very quckly whereas your current tread has a much longer visibility.