If M is recognizing L in polynomial time, is it also deciding it in polynomial time? Assume that a given turing machine $M$ accepts words in the language
  in $n^k$ or less steps, but words that aren't in the language
  are rejected in unknown number of steps (the machine might even loop).
  
  $k$ is unknown.
  
  Is $L(M)\in P$?


Well, obviously $L(M)$ is recognized in polynomial time. The question is whether it's possible to decide $L(M)$ in polynomial time.

It seems to me that the answer is no, but I can't figure a way to prove it.
It is indeed possible. Simulate $M$ for $n^k$ steps. If it has accepted so far, accept. Otherwise, reject. You can simulate $M$ for $n^k$ steps in polynomial time (perhaps $O(n^{2k})$), hence this is a polynomial time algorithm.