From history it seems that you might be having impacted wisdom tooth
or lax tm joint muscles giving rise this problem.
While yawning during sleep there might be sab-laxation of TM joint producing opening mouth and unable to close.
This happens in impacted molar tooth as well.
Consult oral surgeon and get examined.
Ok and take care.