How about this:
As you assumed, $P$ has terminal singularities, which means that the singular locus of $P$ has codimension at least 3 (see Corollary 5.18 in Kollár-Mori's book). Hence, the singular locus has codimension at most 2 in $X$. We can consider everything outside the singular locus because we work on the level of divisors of $X$. Hence $P$ is just smooth and $X$ is Cartier and everything is true for you.


EDIT:
@LiYutong, of course I did not mean that $K_P$ is Cartier (which is not true in general). I mean that there exists a codimension 3 subset $Z$ of $P$ such that $U=P-Z$ is smooth and hence $X|_U$ is Cartier divisor on $U$. Hence $K_{X|_U}=(K_U+X|_U)|_{X|_U}$ is $\mathbb{Q}$-trivial by adjunction. Note that $X-X|_U$ has codimension at least 2 in $X$, so the Weil divisors class $\rm{Cl}(X)$ on $X$ coincides with  the Weil divisors class $\rm{Cl}(X|_U)$ on $X|_U$ by restriction.
 So $K_X\sim_\mathbb{Q}0$.