Can I catch the trigger of Undeploy API Proxy through the Java Callout code?
I would like to catch this trigger and close all the existing threads.
No, there is no lifecycle management for Java Callouts. They're expected to be stateless.
If you have something stateful, you should be running that in an external system - something like Cloud Run or etc.