You must return the deposit in the matter specified in the contract.  Most contracts require a return of the deposit once the mortgage denial is provided to the seller.