I met this problem also today, and I found the solution is, in the end of your main method (or thread), you should close your Session Factory, like:
sessionFactory.close();
And then, your program will terminate normally.
If You use JavaFX 8 in main method add:
@Override
public void stop() throws Exception {
sessionFactory.close();
}
This method will close session factory and destroy thread on program exit.