Timer1 and PWMS

Hello guys,
i use the code below to steer my DC motor (with H-bridge and bootstrap circuit) with Atmega328 and it works fine for me, but i would like to turn off the pwms/timer1 on one side of the bridge (PIN 9 and 10) after short time (for example 2 secs) of being on. any thoughts how to do it ? I tried to reset TCCR1B after 2 secs standard delay() but it didn’t work for me (seems like timer just ignore delay and everything after it).

#include <avr/io.h>
void InitPorts1(void)
{
  DDRB |= (1 << PB1) | (1 << PB2); 
  DDRD |= (1 << PD6) | (1 << PD5); 
}
void InitTimer1(void)
{
  TCNT1 = 0;
  TCCR1A |= (1 << COM1A1) | (1 << COM1B1) | (1 << COM1B0);
  ICR1 = 65000;
  TCCR1B |= (1 << WGM13);
  OCR1A = 22250;
  OCR1B = 22400;
}
void StartTimer1(void)
{
  digitalWrite(5, LOW);
  delayMicroseconds(100);
  digitalWrite(6, HIGH);
  TCCR1B |= (1 << CS11) | (1 << CS10);
}
int main(void)
{
  InitPorts1();
  InitTimer1();
  StartTimer1();
  while (1)
  {

  }
}

And what’s more the code doesn’t work properly when i put it in standard void setup and void loop configuration of ArduinoIDE. When the code is in main function diodes on Pins 9 and 10 blinks alternately and the one on Pin 6 stays on, but when i put them in setup and loop version diodes on Pin 9 and Pin 6 stays on and the one attached to Pin 10 is off. What’s wrong ?

If you do it the normal way with setup and loop, prior to setup() being called, it calls init() which sets up the timers for PWM. So TCCR1A and TCCR1B are not in the state you're assuming - the solution is to set them to a known value, not just flip a few bits and assume the rest are in their power-on state.

Use millis() to track time passage. Turn off output compare with the COM1A/COM1B bits in TCCR1A