Ok, you don't SW_HIDE or close but the program still terminates. That sounds like an unhandled exception to me. Try running it under the debugger and see if the debugger traps the exception, if not then change the exception handling in the debugger to trap all exceptions and see if anything can enlighten you as to why your program is terminating. It's definitely a bug, you just need to find it.