Fix leave functionality