I am curious to know if we can do this in Powershell.

with Out-File command we can pipe it to get output written to a file. That way I can send all my history commands to a text file.

The Question is Can I send my history commands to a text file every time I exit?  

I don't know if this would be of big help but sometimes if you wrote some one liners and you quit the PS console accidentally then all the history commands will be saved to a text file just like recent chat conversations.