Shared segment after stopping all the processes attached to it?

If we want the operating system to release a shared segment after stopping all the processes attached to it, it should me marked for deletion. But the problem here is that I want to start a new instance of the program and if I delete the shared segment, the new program will not be able to attach to the segment. Can anybody suggest a way to mark the shared segment for deletion at the same time attach to the segment?
