To demagnetise a permanent magnet place it inside a solenoid, pointing East-West, through which an alternating current is flowing. While the current is still flowing, the small atomic magnets present in the permanent magnet get disoriented and hence the permanent magnet gets demagnetised.