<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop_server(self):
 """ Stop receiving connections, wait for all tasks to end, and then terminate the server. """

        self.stop = True
        while self.task_count:
            time.sleep(END_RESP)
        self.terminate = True