terminate(true);
try {
RunningState running = repository.runningState();
long lifetime = Math.abs(System.nanoTime() - this.nanosCreated);
Map<String, String> payload = Collections.singletonMap("userId", getUserID());
running.statistics().recordDuration(DurationMetric.SESSION_LIFETIME, lifetime, TimeUnit.NANOSECONDS, payload);
running.statistics().decrement(ValueMetric.SESSION_COUNT);
running.removeSession(this);
} catch (IllegalStateException e) {
// The repository has been shutdown
} finally {