Fix improper resource shutdown or release (CWE ID 404)