That is entirely dependent on how your program works and where it processes that input. Some options (assuming C):
exit(0);
kill(getpid(), SIGTERM); // or, to send it to the group: kill(-getpid(), SIGTERM);
kill(getpid(), SIGKILL); // or, to send it to the group: kill(-getpid(), SIGKILL);
return 0; // from the main() function
throw std::exception(); // assuming C++, and that you catch (std::exception) somewhere appropriate (like the end of your main() function)
It also depends on what you mean by "graceful," as some will argue that exit(0); is not graceful because it doesn't allow you to do any clean up, whereas others will argue it is graceful because the OS will, in some way, do any cleanup you failed to do.