Added the loop.onCleanup method to receive a callback right before the loop gets destroyed