Once I've started server.accept(), how can I stop it correctly (for example if the user hits exit) so that I am able to restart it a second time in the same fashion (the user wants to start it again)

What part of my code looks like:
server = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
channel = socket.bt_rfcomm_get_available_server_channel(server)
server.bind(("", channel))
socket.bt_advertise_service(unicode(SERVICE_NAME), server, True, socket.RFCOMM)
socket.set_security(server, socket.AUTH | socket.AUTHOR)
conn, client_addr = server.accept()
# Once here, the phone application just waits, nothing happens
- server.close() doesn't accomplish the desired effect. I already tried it.
- I am able to accomplish the desired effect IF a client connects, than I can close the connection; and doing the whole process again works well. The problem is that if noone connects, the accept() just seems to hang.