Implement Promise.whenFinished