I have lived in two cities on the western coast of India and I have seen quite a few of these insects(?) in both places.

Weird insect

It basically has an outer cocoon of sorts, which looks a lot like dirty lint. The actual insect is a small wormlike creature at the top of the cocoon. It almost always tries to keep climbing up walls and when it dies, it remains stuck to the wall from its topmost point. The overall length of it, including the linty cocoon is about half a centimeter.

Can someone tell me what these are and if I need to actively avoid them or prevent their appearance in my closet?