After the cause is submitted to the jury, it may be discharged when it cannot agree and both parties consent to its discharge; or the court may in its discretion discharge it where it has been kept together for such time as to render it altogether improbable that it can agree.