Unexpected crash upon application exit