I am wondering if my sentence is grammatically correct. Peter had hardly gone to sleep, when the knocking at the window jolted him awake.