/**
  * cleans up the current thread. if a current request is set and the request object implements the
  * WebRequest interface then the exit function is called.
  *
  * @param exitCode the exitCode
  */
 protected static void exit(int exitCode) {
   Object reqObj = currentRequest.get();
   if (reqObj != null) {
     if (reqObj instanceof WebRequest) {
       ((WebRequest) reqObj).exit(exitCode);
     }
     // Clear Thread local
     currentRequest.set(null);
   }
 }