 <p>Your best bet is to provide a method to clean up the library. The end user will have to call it (presumably based on handling application lifecycle in the container). You could also provide a <code>Listener</code> for those cases when it is used in a compatible servlet container (e.g., Tomcat), but your end user will still have to be aware and put the descriptor in the web.xml.</p> <p>The only other alternative is that your end user is going to have to create a Listener that manages to get the thread to die. I have had to do this on several occasions and it is not pretty. It usually involves using reflection to get ahold of the thread and killing it. Of course, the ThreadDeath exception is handled by some libraries and the threads refuse to die. This then requires more significant use of reflection to clean up the mess.</p> <p>Your end users are much better off if you give them an easy way to clean up the library. It sucks that they have to know about your implementation details, but they already do because you are keeping the app from unloading.</p>