(Wanted to put this as a comment, but I am not allowed)
Are you using a spring executor (e.g. ThreadPoolTaskExecutor)?
If so, could this happen because spring's executor implementations have highest smartLifeCycle phase value and so they are shutdown earlier than embedded web server?