Crash in SDL_audio.c

im working on an sdl 2.0.9 project that is also compiled to the android platform, after alot of crash fixing there is one last issue that i would like to solve.

there is a rare crash that i couldnt reproduce, i assume that the app start/terminate by the os in an unexpected way.

the crash happens in SDL_audio.c in line 775.

i assume that the program is shutting down and after the sdl delay the thread continue and some how the memory is corrupted, is there any way to fix it? maybe to comment out the sdl delay in #ifdef ANDROID ?

this is part of the code that show in addr2line according to google dashboard crash reports :
it happens in the line after the delay


/* Wait for the audio to drain. */
SDL_Delay(((device->spec.samples * 1000) / device->spec.freq) * 2);


return 0;

using the debugger to enter the function i can see that on android its a no op function - an empty one, i will try comment out the delay and the thread deinit and hope for the best, unless some one else can shed some light.