Fix crash in eglTerminate()
At the moment, the gbm_device for the primary device is destroyed before the EGLDisplay is destroyed. This results in a crash in Mesa.
In order to fix the crash, this change ensures that the EGLDisplay is destroyed before the gbm device.
Edited by Vlad Zahorodnii