Check that the provided stream pointer is really opened for the group before closing & freeing it. Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>