To prove or disprove that $E$ is closed in $X$, I thought $X \smallsetminus E$ should be open in $X$. $$(X \smallsetminus E)=(X \smallsetminus K) \cup (K \smallsetminus E)$$ $X \smallsetminus K$ is open since $K$ is compact in $X$, which means that $K$ is closed in $X$. $K \smallsetminus E$ is also open since $E$ is closed relative to $K$. Union of open sets are open, so $X \smallsetminus E$ is open.
But I think the answer should be $E$ is not closed relative to $X$. I can't find the problem in my proof and I don't know how to solve this.
If your space $X$ is Hausdorff then $E$ is closed relative to $X$ since $K$ is then closed. But if $X$ is for example infinite set with cofinite topology then $E$ doesn't need to be closed relative to $X$, because in this space every set is compact and there are non-closed sets.