There are two functions you should use to quit a window:
destroy()
quit()
Here you have the code using one of the two:
import Tkinter
import tkMessageBox
import time
import sys
def endProgam():
# top.quit()
top.destroy()
top = Tkinter.Tk()
B = Tkinter.Button(top, text = "Hello", command = endProgam)
B.pack()
top.mainloop()