This is normal for console applications. The console is destroyed when all attached processes end. If you want to keep it open, you need to keep your process running. In C++ you can use
std::string str; std::getline(std::cin, str);
And you'll hit enter to finish the application and let it exit.