fix NullPointerException in krun shutdown hook

Fix for #407

@radumereuta please review.