This has happend to me many times

...
It also happens when I am not submerged and there is no one around. However in this incedence I dont loose any hull integrity. I just hear the banging and crashing etc..
I dont understand why it happens for and it makes no sense to me.
So now when I need to get some sleep, go to work or do other things. I just pause the game and minimize the screen.
But I guess this only will work for you if you leave your PC on 24/7 365 like I do

.