```\nfunction cancelVesting(uint256 categoryId, uint256 vestingId, address user, bool giveUnclaimed)\n        external\n        onlyOwner\n{\n        UserVesting memory userVesting = userVestings[categoryId][vestingId][user];\n\n        if (userVesting.amount == 0) {\n            revert UserVestingDoesNotExists(categoryId, vestingId, user);\n        }\n\n        if (userVesting.startTime + vestingInfos[categoryId][vestingId].period <= block.timestamp) {\n            revert AlreadyVested(categoryId, vestingId, user);\n        }\n\n        uint256 lockupId = lockupIds[categoryId][vestingId][user];\n\n        if (lockupId != 0) {\n            veTRUF.unstakeVesting(user, lockupId - 1, true);\n            delete lockupIds[categoryId][vestingId][user];\n            userVesting.locked = 0;\n        }\n\n        VestingCategory storage category = categories[categoryId];\n\n        uint256 claimableAmount = claimable(categoryId, vestingId, user);\n        if (giveUnclaimed && claimableAmount != 0) {\n            trufToken.safeTransfer(user, claimableAmount);\n\n            userVesting.claimed += claimableAmount;\n            category.totalClaimed += claimableAmount;\n            emit Claimed(categoryId, vestingId, user, claimableAmount);\n        }\n\n        uint256 unvested = userVesting.amount - userVesting.claimed;\n\n        delete userVestings[categoryId][vestingId][user];\n\n        category.allocated -= unvested;\n\n        emit CancelVesting(categoryId, vestingId, user, giveUnclaimed);\n}\n```\n