Hello, and thank you for writing.
If your lender approves your refinance before your divorce is final, you can do whatever you want with the cash out check. But your attorney is in a better position to tell you if that' a good idea.
We primarily provide mortgage advice here, and it would be irresponsible (and possibly illegal) for us to provide legal advice without a license. If an attorney wishes to comment and add a recommendation, he or she is most welcome to do so.