Fix forceClose() and refactor around closing in KernelStatement.

Using the forceClose() method did nothing and resources could leak.
Added a test for it.