I want to liquidate all existing positions intraday and then stop trading 30 mins before the market closes. What would be the best way to do it? 

I have

self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 2), self.Liquidate)

for liquidation 2 minutes before market closes, but it doesn't stop it from entering orders.

Author