Implements logout.