deinitialize correctly in case of fatal error