Perform the shutdown operations in their own thread

The complaint here was that the ShutdownThread inherits the Thread interface and its run method is called directly.
Doing so is bad style and thus this change treats the ShutdownThread class like a thread and executes it in the background waiting for completion - to regain behaviour of the old call semantics.
Ensure everything is finalized properly, especially that the lock is unlocked

The issue here was that due to the method call there was no guarantee that the unlock was reached in case of an exception.
Restructuring the code like this provides this guarantee
[FindBugs] Fix unreachable code due to httpMethod explicitly being initialized earlier in this code path
[FindBugs] Ensure resources are closed/freed properly to avoid memory leaks