[Core] Closed a few resource leaks.

Signed-off-by: Daniel S. Reichenbach <daniel@kogitoapp.com>