How to close window on success?

How to close window on success?

I have a form that displays the 'Data addedd successfully' message on successful submission. How can I have this window close automatically after this message appears? Is there a on success command for close window?